XML uses the same building blocks that HTML does: elements, attributes, and values.
An XML element is the most basic unit of your document.
An XML element can contain other elements and text.
An element has an opening tag with a name ( written between < and > ) and sometimes attributes.
The name should describe the element's purpose.
XML is self-describing
<name>
<first>Bond</first>
<last>James</last>
</name>
Hierarchies in XML
<name>
<first>Bond</first>
<middle>JK</middle>
<last>James</last>
</name>
<name> is parent of <first>, <middle> and <last>.
<first>, <middle> and <last> are sibling.
Text is a child of the element.
The text Bond is a child of <first>.
<name>
<first>Bond</first>
<middle>JK</middle>
<last>James</last>
</name>
<name> element has only other elements, and not text, then it is said to have element content.
<first>, <middle>, and <last> have only text as children, they are said to have simple content.
Elements can contain both text and other elements(mixed content)
<doc>
<parent>this is some <em>text</em> in my element</parent>
</doc>
<parent>has three children:
A text child containing the text 'this is some' and an <em>child.
Another text child containing the text inmyelement.
1.1.Introduction |
| 1.1.1. | Elements, Attributes, and Values |
| 1.1.2. | Text content |