An XML file contains XML-elements, also called XML-nodes or XML-tags
<?xml version="1.0" encoding = "UTF-8"?>
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <phone>(011) 123-4567</phone>
</student>
The names of XML-elements are enclosed by triangular brackets
< >
<element>
Each XML-element
needs to be closed
either with start or with end elements as shown below
<element>...</element>
XML allows self-closing elements, for example if the tag empty
<?xml version="1.0"?>
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <address/>
   <phone>(011) 123-4567</phone>
</student>
Children elements must not overlap parent elements. i.e., an element end tag must follow all of its children's end tags.
<company>
is closed after the
</contact-info>
tag but it's opened after
</contact-info>
tag, which is wrong!
<?xml version = "1.0"?>
<contact-info>
<company>Learn Practice Teach
</contact-info>
</company>
The following example shows the correct nested tags
<?xml version = "1.0"?>
<contact-info>
   <company>Applications.ge</company>
<contact-info>
One
root element
is necessary for an XML document. In this example below, both
<x>
and
<y>
elements are at the top level and they don't have one parent element, which is wrong:
<?xml version = "1.0"?>
<x>...</x>
<y>...</y>
XML-elements are
case-sensitive
, which means that the start and the end elements names need to be exactly in the same case. This example is not correct XML document, because
case sensitivity
is not correctly applied
<?xml version="1.0"?>
<student>
   <name>George</name>
   <city>Tbilisi</city>
   <address/>
   <phone>(011) 123-4567</Phone>
</student>
In this case
<phone>
and its close tag
</phone>
is not in the same case
by Valeri Tandilashvili
4 years ago
XML
XML Tutorial
0
Pro tip: use ```triple backticks around text``` to write in code fences