C#的XML文件格式
时间: 2023-06-21 12:05:38 浏览: 189
C#中的XML文件格式与标准的XML文件格式相同,可以使用XmlTextWriter或XmlDocument类来创建和操作XML文件。以下是一个示例XML文件格式:
```
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
<description>After the collapse of a nanotechnology
society in England, the young survivors lay the
foundation for a new society.</description>
</book>
</catalog>
```
在此示例中,`<?xml version="1.0" encoding="UTF-8"?>`声明了XML版本和编码格式。`<catalog>`是根元素,包含了三个`<book>`元素。每个`<book>`元素都有一个唯一的id属性,以及作者、标题、类型、价格、出版日期和描述等子元素。
阅读全文