测试之路,与你同行!

XML文档实例1

上一篇 / 下一篇  2010-01-27 11:24:55

<?xml version='1.0' encoding='ISO-8859-1'?>  /XML声明,定义XML的版本(1.0)和所使用的编码

(ISO-8859-1=Latin-1/西欧字符集)/

<note> /根元素,本文档是一个便签/

<to>George</to>

<from>John</from>

<heading>Reminder</heading>

<body>Don't forget the meeting!</body>

</note>

1、XML文档必须包含根元素。该元素是所有其他元素的父元素。XML文档形成一种树结构。

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

实例:

上图表示下面的 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'>
<titile lang='en'>Learning XML</title>
<author>Erik </author>
<year>2003</year>
<price>40</price>
</book>
</bookstore>
例子中的根元素是 <bookstore>。文档中的所有 <book> 元素都被包含在 <bookstore> 中。

<book> 元素有 4 个子元素:<title>、< author>、<year>、<price>。

 


TAG:

 

评分:0

我来说两句

Open Toolbar