Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/10/2011, 06:33
roboty
 
Fecha de Ingreso: abril-2011
Mensajes: 867
Antigüedad: 13 años
Puntos: 5
no me muestra los datos de mi xml usando el dom de js

Hola estoy en practicas y estoy probando un pequello codigo pero no me funciona, trata de mostrar los datos de un archivo xml el codigo es este:

Código HTML:
Ver original
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <script type="text/javascript">
  5.   function objetoAjax(){
  6. if (window.XMLHttpRequest)
  7.  _ajax = new XMLHttpRequest();
  8.  else
  9.  if (window.ActiveXObject)
  10.  _ajax = new ActiveXObject("Microsoft.XMLHTTP");
  11.  else
  12.  _ajax = false;
  13.  return _ajax;
  14.  }
  15.  function ResultadosXml(){
  16.     contador=0;
  17.     http= objetoAjax();
  18.     http.open('post','archivo.xml');
  19.     http.onreadystatechange = function() {
  20.                 if(http.readyState == 4){
  21.                     if(http.status == 200) {
  22.                         xml=http.responseXML;
  23.                          document.getElementById("registro").innerHTML = xml.getElementsByTagName('nombre')[contador].firstChild.nodeValue+"</br>";
  24.                         contador++;
  25.                     }
  26.                 }
  27.     }
  28.  }
  29.  
  30. </head>
  31. <div id="registro"><div>
  32. </body>
  33. </html>

cualquier explicacion se agradece saludos.