Create XML in JavaScript

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 … Read more

Appending an existing XML file with XmlWriter

you can use Linq Xml XDocument doc = XDocument.Load(xmlFilePath); XElement school = doc.Element(“School”); school.Add(new XElement(“Student”, new XElement(“FirstName”, “David”), new XElement(“LastName”, “Smith”))); doc.Save(xmlFilePath); Edit if you want to add Element to Existing <Student>, just add an Attribute before school.add(new XElement(“Student”, new XAttribute(“ID”, “ID_Value”), new XElement(“FirstName”, “David”), new XElement(“LastName”, “Smith”))); Then you can add further Details to … Read more