public static void Main(string[] args)
{
//using System.Xml
XmlDocument doc = new XmlDocument()
doc.Load(你的文件存放地址)
XmlElement node = doc.DocumentElement
ReadXml(node.ChildNodes)
Console.ReadLine()
}
private static void ReadXml(XmlNodeList nodes) //遍迟纳历
{
foreach (XmlNode node in nodes)
{
if (node.Value != null &&node.Value.Trim().Length >0)
{
Console.WriteLine(node.Value)
}
ReadXml(node.ChildNodes)
}
}
首改纳先将XML加载核前没进来private void Form1_Load(object sender, EventArgs e)
{
doc.Load(XML的文件名称)
}
//按钮的事件
private void button4_Click(object sender, EventArgs e)
{
XmlNodeList xmllist = doc.SelectSingleNode("grandpa").ChildNodes
for (int i = 0i <悔薯 xmllist.Counti++)
{
XmlElement xel = xmllist[i] as XmlElement
str += xel.GetAttribute ("name"),
XmlNodeList xnlist = xel.ChildNodes
foreach (XmlNode xmlnode in xnlist)
{
str += xnlist.GetAttribute("name")
}
}
doc.Save("XML的名字")
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)