In this tutorial you will learn about the XML Element and its application with practical example.
The XML Element is combination of opening-tag, data and closing-tag . The data may be plain text or child elements, or a combination of text and child elements. An XML Document is consist of a tree of XML Elements with a single root element as shown below.
Table Of Contents−
Syntax:
1 2 3 4 |
<root_element> <sub_element_1> sub-element 1 </sub_element_1> <sub_element_2> sub-element 2 </sub_element_2> </root_element> |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 |
<inbox> <message id="1"> <from>John</from> <subject>Test Message 1</subject> <body>Hello John!</body> </message> <message id="2"> <from>Chris</from> <subject>Test Message 2</subject> <body>Hello John!</body> </message> </inbox> |