Created
September 27, 2012 16:58
-
-
Save supershabam/3795107 to your computer and use it in GitHub Desktop.
javascript: serialize xml cross browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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