Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/08/2005, 18:06
Avatar de derkenuke
derkenuke
Colaborador
 
Fecha de Ingreso: octubre-2003
Ubicación: self.location.href
Mensajes: 2.665
Antigüedad: 20 años, 6 meses
Puntos: 45
IE me tortura al traer el XML

Tengo un codigo muy sencillito, que funciona en Opera y en Firefox. Pero el maldito IE me dice que "El objeto no acepta esta propiedad o método" en la linea que os dire luego, al analizar el XML. Codigo javascript:

Código PHP:
var req;
function 
loadXMLDoc(url) {
    
// branch for native XMLHttpRequest object
    
if (window.XMLHttpRequest) {
        
req = new XMLHttpRequest();
        
req.onreadystatechange processReqChange;
        
req.open("GET"urltrue);
        
req.send(null);
    
// branch for IE/Windows ActiveX version
    
} else if (window.ActiveXObject) {
        
req = new ActiveXObject("Microsoft.XMLHTTP");
        if (
req) {
            
req.onreadystatechange processReqChange;
            
req.open("GET"urltrue);
            
req.send();
        }
    }
}


function 
processReqChange() {
    
// only if req shows "complete"
    
if (req.readyState == 4) {
        
// only if "OK"
        
if (req.status == 200) {
              
// processing statements
              
response  req.responseXML.documentElement;
              
method response.getElementsByTagName('method')[0].firstChild.data;
              
hora response.getElementsByTagName('hora')[0].firstChild.data;
              
autor response.getElementsByTagName('autor')[0].firstChild.data;
              
texto response.getElementsByTagName('texto')[0].firstChild.data;
              
result response.getElementsByTagName('result')[0].firstChild.data;
              eval(
method+'("'+hora+'","'+autor+'","'+texto+'")');
        } else {
            
alert("There was a problem retrieving the XML data:\n" req.statusText);
        }
    }

Lo demas creo que es irrelevante.

Pues me da un error en la segunda funcion, a la hora de traer el autor. Es esta linea
Código PHP:
autor response.getElementsByTagName('autor')[0].firstChild.data
y no entiendo lo que hago mal. El caso es que la hora si la trae bien, puedo hacer un alert de ella sin problemas. La hora contiene un espacio, es el resultado de un microtime() de php.

Bueno si sirve de algo el XML es muy tonto:
Código PHP:
<?php
header
('Content-Type: text/xml');

$aut=$_GET["autor"];
$txt=$_GET["texto"];

$hora=microtime();

?>
<?php 
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'?>
<response>
<method>agregaFila</method>
<hora><?=urlencode($hora)?></hora>
<autor><?=urlencode($aut)?></autor>
<texto><?=urlencode($txt)?></texto>
<result>1</result>
</response>
Sin mas, me vuelve loco el maltido IE :-p :-p
__________________
- Haz preguntas inteligentes, y obtendrás más y mejores respuestas.
- Antes de postearlo Inténtalo y Búscalo.
- Escribe correctamente tus mensajes.