Model structured documents with elements, attributes, namespaces, schemas, parsing, and transformations.
Lessons
Convert a node tree back into an XML string.
Serializing XML is easiest to learn by reading the example, changing it, and observing the result.
const doc = document.implementation.createDocument('', 'lessons', null);
const lesson = doc.createElement('lesson');
lesson.setAttribute('level', 'beginner');
lesson.textContent = 'XML Basics';
doc.documentElement.appendChild(lesson);
const xmlString = new XMLSerializer().serializeToString(doc);
console.log(xmlString);Practice the Serializing XML example in a small scratch file, then explain what changed and why.