The Root Element

Each well-formed XML document must contain one element that contains all the other elements. The containing element is called the root element. The root element is a very important part of XML documents, especially when you look at them from a programming point of view, because you parse XML documents starting with the root element. In ch02_01.xml, developed at the start of this chapter, the root element is the <DOCUMENT> element (although you can give the root element any name):

<?xml version = "1.0" standalone="yes"?> 
<DOCUMENT> <CUSTOMER> <NAME> <LAST_NAME>Smith</LAST_NAME> <FIRST_NAME>Sam</FIRST_NAME> </NAME> <DATE>October 15, 2003</DATE> <ORDERS> <ITEM> <PRODUCT>Tomatoes</PRODUCT> <NUMBER>8</NUMBER> <PRICE>$1.25</PRICE> ...

Get Real World XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.