¿Cómo serializo un DOM a texto XML, usando JavaScript, de forma cruzada con el navegador?
Tengo un objeto XML (cargado usando XMLHTTPRequest
's responseXML
). He modificado el objeto (usando jQuery) y me gustaría almacenarlo como texto en una cadena.
Aparentemente hay una forma sencilla de hacerlo en Firefox et al:
var xmlString = new XMLSerializer().serializeToString( doc );
(de rosettacode )
Pero ¿cómo se hace en IE6 y otros navegadores (sin, por supuesto, romper Firefox)?
25
Author: Alexander Elgin, 2008-09-04
1 answers
Puede usar doc.xml en internet exlporer.
Obtendrás algo como esto:
function xml2Str(xmlNode) {
try {
// Gecko- and Webkit-based browsers (Firefox, Chrome), Opera.
return (new XMLSerializer()).serializeToString(xmlNode);
}
catch (e) {
try {
// Internet Explorer.
return xmlNode.xml;
}
catch (e) {
//Other browsers without XML Serializer
alert('Xmlserializer not supported');
}
}
return false;
}
Lo encontré aquí.
35
Author: Huppie,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-08-15 12:39:41
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-08-15 12:39:41