function loadXMLString(string) {
if(window.DOMParser) {
var XMLString = new DOMParser().parseFromString(string, "text/xml");
}
else {
var version = ['MSXML2.DOMDocument',
'MSXML2.DOMDocument.3.0',
'MSXML2.DOMDocument.4.0',
'MSXML2.DOMDocument.5.0',
'MSXML2.DOMDocument.6.0'],
i = version.length;
while(i--) {
try {
var XMLString = new ActiveXObject(version[i]);
}
catch(error) {
//throw new Error(error.message);
}
}
XMLString.async = 'false';
XMLString.loadXML(string);
}
return XMLString;
}
var xml = loadXMLString(
'<parent>\
<element>text<element>\
</parent>'
);
function getData(node) {
var childrens = node.childNodes,
i = childrens.length,
array = [];
while(i--) {
var data = node.childNodes[i];
data.hasChildNodes() && array.unshift(data);
}
return array;
}
alert(getData(xml.documentElement)[0].firstChild.nodeValue);
дальше тем же/подобным макаром сами