XML Tree(树形结构)
xml文檔(xml document)使用樹形結構表達,以根結點root為開始,逐漸向下發散。它使用一種可自我描述的簡單的語法.
一個xml文檔分為文件序言(declaration)和文件主體兩個大的部分。以figure 1為例,文件中的第一行即是文件序言,它是一個XML?文件必須要聲明的東西,而且也必須位于XML?文件的第一行,它主要是告訴XML?解析器如何工作。接下來則是根元素root element(Figure 1里的note), 后面四行則是node的子節點child elements.而最后一行則是根節點完結標識。在xml里,每個element都需要有匹配的結束標記,如<note>與</note>,<to>與</to>,<body>與</body>...
?
Figure 1:
?
?<?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>
?
?
下面是一個xml文檔,我們可以通過它構建一個xml結構示意圖(figure 2). 在figure 2里,bookstore作為根元素,是整個樹結構的起始端,所以book元素作為子元素(child),包含在它下面;而<title>,< author>, <year>, <price>,則是作為book元素的子元素,包含在book下面.通過這種方式,形成樹形結構。
?
<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">Learning?XML</title>
????<author>Erik?T.?Ray</author>
????<year>2003</year>
????<price>39.95</price>
??</book>
</bookstore>
?
Figure 2:?
?
?
?要了解更多,可以訪問:http://www.w3schools.com/xml/xml_tree.asp
?
?
轉載于:https://www.cnblogs.com/iswszheng/archive/2009/05/18/1459213.html
總結
以上是生活随笔為你收集整理的XML Tree(树形结构)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 英语口语(5月17)
- 下一篇: PPP 配置和验证