../courses.php
XML
XML105
3
Understand An XML Document
An XML document is a complete structured file with one root element.
What makes something an XML document?
An XML document is a complete XML file that follows XML rules and contains one root element holding the document together.
Individual XML elements are useful, but real XML is stored as complete documents.
Every XML document has exactly one root element.
Everything else appears inside that root.
The document may contain hundreds or thousands of nested elements.
Programs read the document from the root and work downward through the tree.
A complete XML document
<library>
<book>
<title>Learning XML</title>
<author>Maya</author>
</book>
<book>
<title>Web Standards</title>
<author>Alex</author>
</book>
</library>
The root element is <library>.
Each book is a child element.
Each title belongs to one book.
Each author belongs to one book.
The document forms a hierarchy called a tree.
Organization
One root keeps everything together.
Reading
Programs can process one branch at a time.
Exchange
Complete XML documents move easily between systems.
Consistency
Every XML parser expects one document root.
Two roots
<books></books>
<people></people>
One root
Ask ChatGPT: "Does this XML document have exactly one root element and is every other element inside it?"
Create one XML document.
Add two book elements.
Add title and author.
Identify the root element.
Explain why two roots are invalid.
Creating two root elements.
Placing elements outside the root.
Thinking every top-level element is a root.
Ignoring document structure.
Mixing unrelated records together.
Identify the root element and recognize a complete XML document.
Login - Jit4All
Login
Welcome back to Jit4All