XML Elements & content
Elements & Content : XML Document
In the last chapter we have seen different optional parts of XML document. In this chapter we are going to learn different mandatory fields of XML document.
Explanation :
Consider this example -
<Student> <Boy> <name>Pritesh</name> <marks>90</marks> </Boy> <Girl> <name>Pooja</name> <marks>89</marks> </Girl> </Student>
In the above example -
1. Root Node
<Student>
2. Sub Nodes
<Boy> and <Girl>
are siblings of each other and Children nodes of <Student>
3. Sub-Sub Nodes
<name> and <marks>
Again for Each <Boy> and <Girl> have two child nodes.
XML Tree Structure :
Alternate Way for Above XML Document :
<Student> <Boy name="Pritesh" marks="90"></Boy> <Boy name="Pooja" marks="89"></Boy> </Student>
Root Element :
- Each XML Document must have One and Only One Root Element.
- Other XML elements must be Nested inside Root Element.
- Opening Tag of Root Element is the Opening Tag of Document.
- Closing Tag of Root Element is the Closing Tag of Document.
Some Facts :
- XML is Organized as Tree Structure.
- XML can have User Defined Tags.
- XML consists of any number of nodes.
Elements & Content
Root element opening tag |
<Person> |
Child elements and content |
<Student> <Boy> <name>Pritesh</name> <marks>90</marks> </Boy> <Girl> <name>Pooja</name> <marks>89</marks> </Girl> </Student> |
Root element closing tag |
</Person> |