日期:2014-05-18 浏览次数:21049 次
<?xml version="1.0" encoding="utf-8"?> <School sname="aa"> <Class cname="c1"> <Student name="bb" age="21"> </Student> <Stu name="stu1" /> </Class> <Class cname="c2"> <Student name="cc" age="22"> </Student> </Class> </School>
public List<string> count_list = new List<string>(); public void GetNodeName(XmlNode xn) { string name = xn.Name; if (!count_list.Contains(name)) count_list.Add(name); if (xn.HasChildNodes) { foreach (XmlNode temp in xn.ChildNodes) { GetNodeName(temp); } } }