读取XML文件:
using System;
using System.Xml;
class TestReadXML
{
public static void Main()
{
XmlTextReader reader = new XmlTextReader("C:\\test.xml");
reader.Read();
while (reader.Read())
{
reader.MoveToElement();
Console.WriteLine("XmlTextReader Properties Test");
Console.WriteLine("===================");
// Read this properties of element and display them on console
Console.WriteLine("Name:" + reader.Name);
Console.WriteLine("Base URI:" + reader.BaseURI);
Console.WriteLine("Local Name:" + reader.LocalName);
Console.WriteLine("Attribute Count:" + reader.AttributeCount.ToString());
Console.WriteLine("Depth:" + reader.Depth.ToString());
Console.WriteLine("Line Number:" + reader.LineNumber.ToString());
Console.WriteLine("Node Type:" + reader.NodeType.ToString());
Console.WriteLine("Attribute Count:" + reader.value.ToString());
}
}
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。