Skip to content
Related Articles

Related Articles

XML | Tags
  • Difficulty Level : Basic
  • Last Updated : 21 Sep, 2018

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:




    <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:




    <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:




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

    
    

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




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

    
    

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




    <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.




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

    
    




My Personal Notes arrow_drop_up
Recommended Articles
Page :