精彩专题推荐:建站之入门课 建站之必修课 建站之关键课 网站价值所在 流量提高专题 css+div 标准 个人网站打造全过程

xml 文档树

来源:网络翻译整理 时间:08-04-12 点击: 点击这里收藏本文

XML documents form a tree structure that starts at "the root" and branches to "the leaves".
XML 文档树起始于“根元素”,并以此为基础扩展文档的分支结构。


An Example XML Document
下面举一个XML文档案例

XML documents use a self-describing and simple syntax:
XML 文档使用一种相对简单的自述性语法:

<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>

The first line is the XML declaration. It defines the XML version (1.0) and the encoding used (ISO-8859-1 = Latin-1/West European character set).
代码的第一行对XML文档做出了声明。它定义了XML版本号(1.0)以及文档所使用的字符编码(ISO-8859-1:拉丁文/西欧字符集)。

The next line describes the root element of the document (like saying: "this document is a note"):
接下来的一行定义了文档的根元素(指明该文档是一份便条):

<note>

The next 4 lines describe 4 child elements of the root (to, from, heading, and body):
再接下去的4行定义了根元素的4个子元素,分别是“to”、“form”、“heading”和“body”:

<to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body>

And finally the last line defines the end of the root element:
文档的最后一行定义了根元素的结束标签:

</note>

You can assume, from this example, that the XML document contains a note to Tove from Jani.
举个例子来说,你可以假设这份XML文档是Jani递交给Tove的一张便条。

Don't you agree that XML is pretty self-descriptive?
通过上述案例,对于XML是一种完美的自述性语言这点应该毋庸置疑了吧?


XML Documents Form a Tree Structure
XML 树状结构文档

XML documents must contain a root element. This element is "the parent" of all other elements.
XML 文档必须包含一个根元素。这个根元素是其它所有元素的“父元素”。

The elements in an XML document form a document tree. The tree starts at the root and branches to the lowest level of the tree.
这些元素位于XML树状结构文档内。树状结构起始于根元素,并向更低级别的树状分支结构扩展。

9 7 3 1 2 4 8 :

广而告之