xml 文档树
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 文档必须包含一个根元素。这个根元素是其它所有元素的“父元素”。![]()
文章评论
共有 0人发表了评论 查看完整内容