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
End tagEvery element that has a start tag should end with an end tag.
Example
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
- <empty> & <empty></empty>
XML Rules
- All XML must have a root element.
Example
- <roots>
- <name>Shresth Jaiswal</ name>
- <date of birth>2nd October 1999</ date of birth>
- </root>
- All the tags in XML must be closed.
Example
- All tags must be properly nested.
Example
Wrong:
- <P><Q>Hello</P></Q>
- <s><t>Hello</s></t>
Right:
- <P><Q>Hello</Q></P>
- <s><t>Hello</t></s>
- All the names of XML tags have strict limits.
Example
Wrong:
Right:
- Tags in XML are case-sensitive.
Example
Wrong:
- <root>Shresth</Root>
- <xml>first page</Xml>
Right:
- <root>Shresth</root>
- <Xml>first page</Xml>
- In XML tags, names cannot contain spaces.
Example
- In XML, attribute values must appear within quotes.
Example
Wrong
- <note date= 18/05/2015>
- </note>
- Right
- <note date= ‘’18/05/2015”>
- </note>
Special meaning