![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
12/03/2013, 07:04
|
![Avatar de IsaBelM](http://static.forosdelweb.com/customavatars/avatar244381_2.gif) | Colaborador | | Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 16 años, 7 meses Puntos: 1012 | |
Respuesta: abrir documento xml pongamos este xml Cita: <?xml version="1.0" encoding="UTF-8"?>
<contenedor>
<caja>
<item name="expediente1">
Contenido del expediente 1 --> María
</item>
</caja>
<caja>
<item name="expediente1">
Contenido del expediente 1.1 --> Andrés
</item>
</caja>
<caja>
<item name="expediente2">
Contenido del expediente 2 --> Juan
</item>
</caja>
</contenedor> para obtener los valores Cita: <!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" xml:lang="es" lang="es">
<head>
<meta http-equiv="Content-Type" content="application/xhtml; charset=utf-8" />
<title></title>
<script type="text/javascript">
function fnc(nodo, attr, valorAttr) {
if (window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else {
xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.open('GET','valornodoporid.xml',false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
col = xmlDoc.getElementsByTagName(nodo);
for (var i = 0; i < col.length; i++) {
if (col[i].getAttribute(attr) && col[i].getAttribute(attr) == valorAttr) {
document.getElementById('valores').innerHTML+= col[i].childNodes[0].nodeValue + '<br />';
}
}
}
</script>
</head>
<body>
<div>
<b>Valores:</b> <span id="valores"></span>
</div>
<form>
<input type="button" onclick="fnc('item', 'name', 'expediente1')" value="Valor del Nodo" />
</form>
</body>
</html> para que funcione en chrome, ie y opera has de estar en el servidor |