Model structured documents with elements, attributes, namespaces, schemas, parsing, and transformations.
Lessons
Read element text, attributes, and node lists.
Accessing Elements & Values is easiest to learn by reading the example, changing it, and observing the result.
const doc = new DOMParser().parseFromString(xmlString, 'application/xml');
const root = doc.documentElement; // root element
const first = root.firstElementChild; // first child element
const lessons = doc.getElementsByTagName('lesson');
for (const lesson of lessons) {
console.log(lesson.getAttribute('level'),
lesson.querySelector('title').textContent);
}Practice the Accessing Elements & Values example in a small scratch file, then explain what changed and why.