Ver Mensaje Individual
  #8 (permalink)  
Antiguo 04/06/2008, 10:01
Avatar de Panino5001
Panino5001
Me alejo de Omelas
 
Fecha de Ingreso: mayo-2004
Ubicación: -34.637167,-58.462984
Mensajes: 5.148
Antigüedad: 20 años, 9 meses
Puntos: 834
Respuesta: Problemas con al crear elementos DOM en IE7

Probé esto con ese xml (lo llamé data.xml) y funciona perfectamente en Explorer 7 y el resto de los navegadores que probé:
Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<
title></title>
<
script>
function $(
id){
    return 
document.getElementById(id);    
}
function 
http(){
     if(
window.XMLHttpRequest){
        return new 
XMLHttpRequest();
    }else{
        try{
            return new 
ActiveXObject('Microsoft.XMLHTTP');
        }catch(
e){
            
alert('Su navegador no soporta AJAX');
            return 
false;
        }
    }
}
function 
mostrar(){
    
H=new http();
    if(!
H)return;
    
H.open('get','data.xml',true);
    
H.onreadystatechange=function(){
        if(
H.readyState==4){
            try{
                var 
nodos=H.responseXML;
                
tabular(nodos);
            }catch(
e){
                
alert('problema al acceder a la información xml')
            }
            try{
                
H.abort();
                
H.onreadystatechange=null;
            }catch(
e){}
        }else{
            
document.getElementsByTagName('body')[0].innerHTML='cargando...';
        }
    }
    
H.send(null);
}
function 
tabular(xml){
    var 
Table=document.createElement('table');
    var 
myTable=document.createElement('tbody');

for (
0xml.getElementsByTagName('factura').lengthi++){
entro true;
var 
ite xml.getElementsByTagName('factura')[i];
var 
id ite.getElementsByTagName('id')[0].firstChild.data;
var 
fecha ite.getElementsByTagName('fecha')[0].firstChild.data;
var 
nFactura ite.getElementsByTagName('nFactura')[0].firstChild.data;
var 
cliente ite.getElementsByTagName('cliente')[0].firstChild.data;
var 
importe ite.getElementsByTagName('importe')[0].firstChild.data;


var 
row document.createElement("tr");
var 
cldChk document.createElement("td");
var 
cldIddocument.createElement("td");
var 
cldFechadocument.createElement("td");
var 
cldFacturadocument.createElement("td");
var 
cldClientedocument.createElement("td");
var 
cldImportedocument.createElement("td");


cldChk.innerHTML "<input type='checkbox' name='rd_factura' value="+id+" onclick='sumaFactura(this)'>";
cldId.innerHTML = + id ;
cldFecha.innerHTML fecha ;
cldFactura.innerHTML nFactura ;
cldCliente.innerHTML cliente;
cldImporte.innerHTML importe ;

row.appendChild(cldChk);
row.appendChild(cldFecha);
row.appendChild(cldFactura);
row.appendChild(cldCliente);
row.appendChild(cldImporte);
myTable.appendChild(row);
}

Table.appendChild(myTable);
document.getElementsByTagName('body')[0].innerHTML='';
document.getElementsByTagName('body')[0].appendChild(Table);

window.onload=mostrar;
</script>
</head>

<body>
</body>
</html> 

Última edición por Panino5001; 04/06/2008 a las 10:24