Quickstart With XML: Part 3

Let us learn something about one of the most important parts of XML, XML tags.

Start tag

The start of every non-empty XML element is marked by a start tag.

Example

  1. <menu><root>  
End tag

Every element that has a start tag should end with an end tag.

Example
  1. </menu>, </root>  



Every Start-tag must have an End-tag

In XML, every element requires a start-tag and an end-tag.

Example




Empty element tag

The text that appears between the start tag and the end tag is known as the content. An element that has no content is an empty element. All empty elements are also known as standalone tags.

Example
  1. <empty> & <empty></empty>  


XML Rules
  • All XML must have a root element.

    Example
    1. <roots>  
    2. <name>Shresth Jaiswal</ name>  
    3. <date of birth>2nd October 1999</ date of birth>  
    4. </root>  
  • All the tags in XML must be closed.

    Example
    1. </root>  
  • All tags must be properly nested.

    Example

    Wrong:
    1. <P><Q>Hello</P></Q>  
    2. <s><t>Hello</s></t>  
    Right:
    1. <P><Q>Hello</Q></P>  
    2. <s><t>Hello</t></s>  
  • All the names of XML tags have strict limits.

    Example

    Wrong:
    1. <01_author>  
    2. <”author”>  
    Right:
    1. <author>  
    2. <_author>  
  • Tags in XML are case-sensitive.

    Example

    Wrong:
    1. <root>Shresth</Root>  
    2. <xml>first page</Xml>  
    Right:
    1. <root>Shresth</root>  
    2. <Xml>first page</Xml>  
  • In XML tags, names cannot contain spaces.

    Example
    1. </NAME>  
  • In XML, attribute values must appear within quotes.

    Example

    Wrong
    1. <note date18/05/2015>  
    2. </note>  
    3. Right  
    4. <note date= ‘’18/05/2015”>  
    5. </note>  

Special meaning


Up Next
    Ebook Download
    View all
    Learn
    View all