Convert XML string to XML Object And XML Object to XML String in JavaScript

The below JavaScript function will convert the XML String to XML Object.
function GetXMLObject(strxml) { var xmlObj; if (window.DOMParser) { parser = new DOMParser(); xmlObj = parser.parseFromString(strxml, "text/xml"); } else { xmlObj = new ActiveXObject("Microsoft.XMLDOM"); xmlObj.async = "false"; xmlObj.loadXML(strxml); } return xmlObj; }

The below JavaScript function will convert the XML Object to XML String
function GetXMLString(objxml) { var xmlString; if (objxml.xml != null) xmlString = objxml.xml; else xmlString = (new XMLSerializer()).serializeToString(objxml); return xmlString; }