Skip to content

Instantly share code, notes, and snippets.

@supershabam
Created September 27, 2012 16:58
Show Gist options
  • Save supershabam/3795107 to your computer and use it in GitHub Desktop.
Save supershabam/3795107 to your computer and use it in GitHub Desktop.
javascript: serialize xml cross browser
/**
* serialize xml to a string cross browser
*/
function xmlStringify(xmlNode) {
// https://developer.mozilla.org/en-US/docs/XMLSerializer
if (typeof XMLSerializer !== 'undefined') {
return (new XMLSerializer()).serializeToString(xmlNode);
}
// IE
if (xmlNode.xml) {
return xmlNode.xml;
}
throw 'no method available to stringify xml';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment