Page 177 - Data Science class 11
P. 177
End Tag
Every element that has a start tag should end with an end-tag. So, for the start tag <address> above, the end tag will
be:
</address>
Note, that the end tags include a solidus ("/") before the name of an element.
Empty Tag
The text that appears between start-tag and end-tag is called content. An element which has no content is termed as
empty. An empty element can be represented in two ways as follows:
• A start-tag immediately followed by an end-tag is as shown below:
<hr></hr>
• A complete empty-element tag is as shown below:
<hr/>
Empty-element tags may be used for any element which has no content.
Rules for XML Tags
In XML each tag is called a node. Each node can have one or more child nodes contained within it.
Following are the rules that need to be followed to use XML tags:
Rule 1
XML tags are case-sensitive. Following line of code is an example of wrong syntax, because of the case difference in
two tags, which is treated as erroneous syntax in XML.
<address>This is wrong syntax</Address>
Following code shows a correct way, where we use the same case to name the start and the end tag.
<address>This is correct syntax</address>
Rule 2
XML tags must be closed in an appropriate order, i.e. an XML tag opened inside another element must be closed
before the outer element is closed. For example:
<outer_element>
<internal_element>
This tag is closed before the outer_element
</internal_element>
</outer_element>
Example 1: Classroom (having two sections A and B) student rolls
<?xml version = "1.0"?>
<Class>
<Name>First</Name>
<Sections>
<Section>
<Name>Class 11-Section A</Name>
<Students>
<Student>Madhuri</Student>
<Student>Ishita</Student>
<Student>Vishishth</Student>
<Student>Arav</Student>
Randomisation 175

