XML·XML from well-formed documents to XSLT

XML basics

Elements, attributes, the prolog and the document tree.

Beginner 12 min read Lesson 1 of 300 Challenge included
What you will be able to do
  • One root element per document.
  • Elements nest; tags must close.
  • Use attributes for metadata, not repeated data.
  • The prolog declares the XML version.

In plain English

XML is a markup language for structured data. A document has one root element and a tree of nested elements. Attributes describe elements but should not replace child data when the value can repeat.

course.xmlHTML
<?xml version="1.0" encoding="UTF-8"?>
<course id="css">
  <title>CSS Grid</title>
  <lessons>
    <lesson minutes="18">Grid basics</lesson>
  </lessons>
</course>
Your turn

Write a root element

Easy

Write the opening and closing tags for a course root with one title child.

HTML · starter
<course>
Check your understanding before moving on.
Knowledge checkQuestion 1

How many root elements can an XML document have?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Well-formedness
Lesson 1 of 300 · 0% of course