Elements
: Elements are logical units of information in an XML document and are enclosed in angular brackets
< >
Tags
: Tags are used at the start and end of elements.
XML Documents must have a single root tag which have to be the parent of all other tags.
[xml]
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
[/xml]
In the below example, the root element is <note>
[xml]
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Michael</to>
<from>Randy</from>
<heading>Invitation</heading>
<body>Party Tonight!!</body>
</note>
[/xml]
All XML elements should have a closing tag(
/>
) otherwise, the error is shown.
[xml]
<!------illegal declaration and not considered----->
<p>This is a paragraph
<!-------Legal declaration and considered----->
<p>This is a paragraph</p>[/xml]
XML elements can have multiple elements of as its children which should not be overlapped.
[xml]
<?xml version="1.0"?>
<contact-info>
<company>SPLessons</company>
<contact-info>
[/xml]
XML Elements names are case-sensitive i.e. when element starts with upper case letter, it should end with upper-case only. Likewise for lower case also.
[xml]
<Message>This is incorrect</message>
<message>This is correct</message>
[/xml]