The basics of XML development: XML tree Architecture

Source: Internet
Author: User
Tags character set

The XML document forms a tree structure that starts at the root and then expands to the foliage.

An instance of an XML document

XML uses simple, self-describing syntax:

<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>George</to> <from>John</from>

The first line is the XML declaration. It defines the version (1.0) of the XML and the encoding used (iso-8859-1 = latin-1/Western Character set).

The next line describes the root element of the document (like, "This document is a sticky note"):

<note>

The next 4 lines describe the 4 child elements of the root (to, from, heading, and body):

<to>George</to> <from>John</from>

The last line defines the end of the root element:

</note>

From this example, it is conceivable that the XML document contains a note by John to George.

Do you agree that XML has excellent self-describing nature?

XML documents form a tree structure

The XML document must contain a root element. The element is the parent element of all other elements.

Elements in an XML document form a tree of documents. The tree begins at the root and expands to the bottom of the tree.

All elements can have child elements:

<root> <child> <subchild>.....</subchild> </child> </root>

The terms parent, child, and sibling are used to describe the relationship between elements. The parent element has child elements. Child elements at the same level become compatriots (brothers or sisters).

All elements can have textual content and attributes (similar to HTML).

Instance

The figure above represents a book in the following XML:

<bookstore> <book category="COOKING"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="WEB"> <title lang="en">LearningXML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore>

The root element in the example is <bookstore>. All <book> elements in the document are included in <bookstore>.

<book> element has 4 child elements:<title>, < author>, <year>, <price>.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.