Model structured documents with elements, attributes, namespaces, schemas, parsing, and transformations.
Lessons
Use DOMParser to read XML in the browser.
Parsing XML in JavaScript is easiest to learn by reading the example, changing it, and observing the result.
const xmlText = `
<lessons>
<lesson level="beginner"><title>XML Basics</title></lesson>
</lessons>`;
const doc = new DOMParser().parseFromString(xmlText, 'application/xml');
const title = doc.querySelector('lesson > title').textContent;
const level = doc.querySelector('lesson').getAttribute('level');
console.log(title, level);Practice the Parsing XML in JavaScript example in a small scratch file, then explain what changed and why.