XML创建、读、写操作
Create:
int nFQ;
XmlDocument doc = new XmlDocument();
XmlAttribute
newAtt;
//定义XML文档头文件
XmlDeclaration dec =
doc.CreateXmlDeclaration("1.0",null,null);
doc.AppendChild(dec);
XmlElement
docRoot = doc.CreateElement("Orders");
doc.AppendChild(docRoot);
for(int i=0;i<12;i++)
{
XmlNode Order =
doc.CreateElement("Order");
newAtt =
doc.CreateAttribute("Quantity");
nFQ = 10*i +i;
newAtt.Value
= nFQ.ToString();
Order.Attributes.Append(newAtt);
docRoot.AppendChild(Order);
}
//
保存XML文档
string strPath = Server.MapPath("OutDocument.XML");
doc.Save(strPath);
Read:
一:
// 创建XmlDocument类的实例
XmlDocument doc = new XmlDocument();
ArrayList
NodeValues = new ArrayList();
// 把people.xml文件读入内存,形成一个DOM结构
doc.Load(
Server.MapPath("people.xml") );
XmlNode root =
doc.DocumentElement;
foreach( XmlNode personElement in
root.ChildNodes )
//吧节点加入数组
NodeValues.Add(personElement.FirstChild.Value);
//在ListBox中显示
XMLNodeListBox.DataSource = NodeValues;
XMLNodeListBox.DataBind();
二:
//读取XML到DataSet
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(".\\db\\dbGuest.xml"));
GridView1.Dat
相关文档:
在使用Goddady主机使用
Google XML
Sitemaps插件的时候,总提示无权限,而实际上我是了权限的,把插件下载到本地,也是可以正常生成sitemap的,怎么办?自然不能难倒咱
Iter。
检索多方检查,发现在服务器上,检查路径一项为sitemap.xml,而在本地,检查路径
为d:\workstation\site\iove.net\sitemap.xml,也就是说 ......
一、测试用的em.xml
<?xml version="1.0" encoding="GB2312"?>
<EW cmd="login" mod="Login" version="6.0">
<Source uns="" type="user"/>
<Username>zhangzhiyun@hp</Username>
<Password>111111</Password> ......
需要添加的命名空间:
using System.Xml;
定义几个公共对象:
XmlDocument xmldoc ;
XmlNode xmlnode ;
XmlElement xmlelem ;
1,创建到服务器同名目录下的xml文件:
方法一:
xmldoc = new XmlDocument ( ) ;
//加入XML的声明段落,<?xml version="1.0" encoding="gb2312"?>
XmlDeclaration xmldecl;
xml ......
XML文件的解析--libxml库函数解释[转]
libxml(一)
摘要
Libxml是一个有免费许可的用于处理XML、可以轻松跨越多个平 ......