xml 文件如下:
<?xml version="1.0" encoding="GBK"?>
<studentlist>
<student>
<name>吴贻龙</name>
<num>8000103124</num>
<age>21</age>
<sex>male</sex>
<englishscores>91</englishscores>
<xmlscores>80</xmlscores>
<umlscores>85</umlscores>
<scholarship>特等</scholarship>
</student>
</studentlist>
程序如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Collections;
namespace oXmlNode
{
class Program
{
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
doc.Load(@"E:\c#\c#_windows程序设计\xml.xml");
XmlNode root = doc.DocumentElement;//获得文档根节点?
IEnumerator NodePointer = root.GetEnumerator();
XmlNode student;
while (NodePointer.MoveNext())
{
student = (XmlNode)NodePointer.Current;
Console.WriteLine(student.OuterXml);
Console.WriteLine("----------------");
Console.WriteLine(student.InnerXml);
Console.WriteLine("----------------");
Console.WriteLine(student.InnerText);
}
}
}
}
结果如下:
评论