OpenXml开发 一个应用Xml的例子
3private XmlDocument xmlDoc;
4 //load xml file
5 private void LoadXml()
6 {
7 xmlDoc=new XmlDocument();
8 xmlDoc.Load("User.xml");
9 }
10 //添加节点
11 private void AddElement()
12 {
13 LoadXml();
14 XmlNode xmldocSelect=xmlDoc.SelectSingleNode("user");
15 XmlElement el=xmlDoc.CreateElement("person"); //添加person节点
16 el.SetAttribute("name","风云"); //添加person节点的属性"name"
17 el.SetAttribute("sex","女"); //添加person节点的属性 "sex"
18 el.SetAttribute("age","25"); //添加person节点的属性 "age"
19 XmlElement&n
相关文档:
wsdl.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="MobilePhoneService"
targetNamespace="www.mobilephoneservice.com/MobilePhoneService-interface"
xmlns="http://schemas.xmlsoap.org/wsdl/"
  ......
book_schema.xml文件
<?xml version="1.0" encoding="gb2312"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="丛书">
<xs:complexType>
<xs:sequence>
<xs:element name="书">
&n ......
大量SmipleXML函数可用来加载和解析大量XML文档。
1.simpleXML_load_file()函数来加载指定的XML文件到对象。如果加载文件时遇到问题,则返回FLASE。例:
book.xml文件:
<?xml version="1.0" standalone="yes"?>
<library>
<book>
<title>Pride and Prejudice</title>
< ......
xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<mobile-list>
<mobile type="Nokia2652">
<wap2>false</wap2>
<width>115</width>
</mobile>
<mobile type="Nokia2650">
......