一个 XML 文档实例

XML 使用简单的具有自我描述性的语法:

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>
</note>

第一行是 XML 声明。它定义 XML 的版本 (1.0) 和所使用的编码 (ISO-8859-1 = Latin-1/西欧字符集)。

下一行描述文档的根元素(像在说:“本文档是一个便签”):

<note>

接下来 4 行描述根的 4 个子元素(to, from, heading 以及 body):

<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Don't forget the meeting!</body>

最后一行定义根元素的结尾:

</note>

从本例可以设想,该 XML 文档包含了 John 给 George 的一张便签。

XML 具有出色的自我描述性,你同意吗?

 posted on 2013-03-30 01:55  Ryan724  阅读(125)  评论(0)    收藏  举报