Difficulty with AJAX pick up values from nodes

0

I would like to separate this data with ajax , but I am having difficulty with nodes :

<?xml version="1.0" encoding="ISO-8859-1"?>
<android_ecs.xml>
<node><IAAUTNUM>2089777</IAAUTNUM></node>
<node><IAAUTNUM>2089777</IAAUTNUM></node>
<node><IAESTORNO>ESTORNADA</IAESTORNO></node>
<node><IAENTNOME>ETD052  ENTIDADE</IAENTNOME></node>
<node><IAASSNOME>TESTES -TEF</IAASSNOME></node>
<node><IAASSPORT>TESTES -TEF</IAASSPORT></node>
<node><IACARTFMT>6298 6901 0001 6680</IACARTFMT></node>
<node><IAPARPRIM>2,33</IAPARPRIM></node>
<node><IAPARCOUT>0,00</IAPARCOUT></node>
<node><IAQTDPAR>1</IAQTDPAR></node>
<node><IAVALOPE>2,33</IAVALOPE></node>
<node><IACODSESAT></IACODSESAT></node>
<node><IANOMMES>JULHO/14</IANOMMES></node>
<node><IADATA>14/07/2014</IADATA></node>
<node><IAHORA>18:39:57</IAHORA></node>
</android_ecs.xml>

    <script>
    function dados(){
    var ajax = false;
    var xml = '';
    if(window.XMLHttpRequest){
    ajax = new XMLHttpRequest;
    }else if(window.ActiveXObject){

    ajax = new ActiveXObject("Microsoft.XMLHTTP");

    }
    //ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    if(ajax){

    ajax.open("GET","http://remote.tecbiz.com.br:8080/tecbiz/tecbiz.php?     a=725d5b&ecs=5054&sen=123456&aut=&acs=3",true);
    ajax.onreadystatechange = function(){
    if(ajax.readyState == 4){
    if(ajax.status == 200){

    xml = ajax.responseText;
    android = xml.getElementsByTagName( "android_ecs.xml" )[0];
    NUMAUT = android.childNodes[0].childNodes[1].nodeValue;
    alert(NUMAUT);

    }else{

    alert('Erro!');

    }

    }

    }
    }
    ajax.send(null);
    }


</script>

p>     

asked by anonymous 17.07.2014 / 16:26

1 answer

1
    function Xhr(){
    try {
        return new XMLHttpRequest();
    }catch(e){}
    try {
        return new ActiveXObject("Msxml3.XMLHTTP");
    }catch(e){}
    try {
        return new ActiveXObject("Msxml2.XMLHTTP.6.0");
    }catch(e){}
    try {
        return new ActiveXObject("Msxml2.XMLHTTP.3.0");
    }catch(e){}
    try {
        return new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){}
    try {
        return new ActiveXObject("Microsoft.XMLHTTP");
    }catch(e){}
    return null;
}

function dados(){
    var ajax  = Xhr();  
    if(ajax != null){
        ajax.onreadystatechange = function() {
            if (ajax.readyState == 4 ) {
               if(ajax.status == 200){
                   /* android = xml.getElementsByTagName( "android_ecs.xml" )[0];
                    NUMAUT = android.childNodes[0].childNodes[1].nodeValue;
                    alert(NUMAUT);*/
                   var xml = ajax.responseXML;
                   var android  = xml.documentElement;
                   alert(android);                 }
               else if(ajax.status == 400) {
                  alert('400')
               }
               else {
                   alert("Erro: "+ajax.status);
               }
            }
        }
        ajax.open("GET", "http://remote.tecbiz.com.br:8080/tecbiz/tecbiz.php?a=725d5b&ecs=5054&sen=123456&aut=&acs=3", true);
        ajax.send();
    }   
}
    
17.07.2014 / 17:38