Create XML In Javascript
Answer : Disclaimer: The following answer assumes that you are using the JavaScript environment of a web browser. JavaScript handles XML with 'XML DOM objects'. You can obtain such an object in three ways: 1. Creating a new XML DOM object var xmlDoc = document.implementation.createDocument(null, "books"); The first argument can contain the namespace URI of the document to be created, if the document belongs to one. Source: https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument 2. Fetching an XML file with XMLHttpRequest var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { var xmlDoc = xhttp.responseXML; //important to use responseXML here } xhttp.open("GET", "books.xml", true); xhttp.send(); 3. Parsing a string containing serialized XML var xmlString = "<root></root>"; var parser = new DOMParser(); var xmlDoc = pa...