Open In App

XML | Tags

Last Updated : 12 Apr, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

XML tags are the important features of XML document. It is similar to HTML but XML is more flexible then HTML. It allows to create new tags (user defined tags). The first element of XML document is called root element. The simple XML document contain opening tag and closing tag. The XML tags are case sensitive i.e. <root> and <Root> both tags are different. The XML tags are used to define the scope of elements in XML document.
Property of XML Tags: There are many property of XML tags which are discussed below: 
 

  • Every XML document must have a root tag which enclose the XML document. It is not necessary to name of root tag is root. The name of root tag is any possible tag name. 
    Example: 
     

html




<root>
    <name>GeeksforGeeks</name>
    <address>
        <sector>142</sector>
        <location>Noida</location>
    </address>
</root>


  • The XML document must have start-tag, so first starting tag is known as root tag. The opening tag started with < bracket followed by tag name or element name and close with > bracket. 
    Example: 
     

html




<Name>GeeksforGeeks
<address>Noida


  • The tag which is started by start tag must end with the same tag with forward slash (end tag), or in other words every XML document must be ended with end-tag. The end tag started with < followed by / and its pair tag name ended with > 
    Example: 
     

html




<Name>GeeksforGeeks</Name>
<address>Noida</address>


  • In XML, tags are case sensitive. It means that <Root> and <root> both are different tags. 
    Example: 
     

html




<Name>Case sensitive</Name>
<name>name and Name are different tag</name>


  • The tag which contains no content are known as empty tags. 
    Example: 
     

html




<name> </name>
<address/>


  • XML tag must be close in appropriate order. For example an XML tag opened inside another element must be closed before the outer element is closed. 
     

html




<root>
    <name>GeeksforGeeks</name>
    <address>
        <add>Sector 142 Noida</add>
        <pin>201302</pin>
        <country>India</country>
    </address>
</root>


 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads