ML Document: The Root Element
In any markup language, the first element to appear is called the "root element", which defines what kind of document the file will be. In an HTML file, the <html> tag is the root element. An HTML file will always have the HTML element as the root element, while in an XML file, it can be anything.XML Code:
<phonebook> <number> </number> <name> </name> </phonebook>
XML Code:
<phonebook> <number> </number> <name> </phonebook> </name>
There Can Be Only One
Another rule for XML files is that only one root element per file is allowed. Our previous example followed this rule, but our example below does not because it has two root elements. What are the two root elements?XML Code:
<phonebook> <number> </number> <name> </name> </phonebook> <diary> <date> </date> </diary>
After the phonebook element is closed, no other elements should follow because XML can only have one root element per file. Because the "diary" element did not follow this rule, it transformed this XML file into a lawless, rule-breaking file!
0 comments:
Post a Comment