Friday 10 July 2009

jQuery - XML to String

In my last post I demonstrated how to convert a string into XML, now I will demonstrate how to reverse this. Once again, Internet Explorer reacts differently to other web browsers, in that it requires ActiveX to do the work.

jQuery.XMLtoStr = function(xmlData) {
if (window.ActiveXObject) {
return xmlData.xml;
} else {
return (new XMLSerializer()).serializeToString(xmlData);
}
}


Usage:

$.XMLtoStr(xmlDoc);

No comments: