XMLTextReader对XML文件的读取
using System;
using System.Xml;
namespace ReadXMLfromFile
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
static void Main(string[] args)
{
XmlTextReader reader = new XmlTextReader ("books.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an element.
Console.Write("<" + reader.Name);
Console.WriteLine(">");
break;
case XmlNodeType.Text: //Display the text in each element.
Console.WriteLine (reader.Value);
break;
case XmlNodeType.EndElement: //Display the end of the element.
Console.Write("</" + reader.Name);
Console.WriteLine(">");
break;
}
}
Console.ReadLine();
}
}
}
相关文档:
工作中遇到需要合并XML的问题,遂从网上查找相关资料,
1、 《 XML merging made easy
》
2 、《java中合并xml文档的设计与实现
》
测试后发现均不符合实际需求,实际需求如下:
file1.xml:
<root>
<a>
<b name="1"/>
</a>
<d /& ......
Retrieving an XML document using Ajax
http://www.javascriptkit.com/dhtmltutors/ajaxgetpost3.shtml
When making a server request in Ajax, the data returned can be in either
plain text/html, or an XML document instead. The later is technically
just a text file as well, but with s ......
需要添加的命名空间:
using System.Xml;
定义几个公共对象:
XmlDocument xmldoc ;
XmlNode xmlnode ;
XmlElement xmlelem ;
1,创建到服务器同名目录下的xml文件:
方法一:
xmldoc = new XmlDocument ( ) ;
//加入XML的声明段落,<?xml version="1.0" encoding="gb2312"?>
XmlDeclaration xmldecl;
xml ......
Query:
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath(".\\db\\dbGuest.xml"));
//User是XML根节点,Name字节点
lbEmail.Text =
doc.SelectSingleNode("//User ......
http://www.cnblogs.com/long2006sky/articles/1258731.html
DataSet转换为xml文件
//将DataSet转换为xml文件
private static void ConvertDataSetToXMLFile(DataSet xmlDS, string xmlFile)
{
&n ......