C# winform XML加载Treeview
XML格式:<xml><c:xmlid="1"name="ceshi1"group="1"uecode="00001"><c:xmlid="2"name="ceshi1....
XML格式:
<xml>
<c:xml id="1" name="ceshi1" group = "1" uecode = "00001">
<c:xml id="2" name="ceshi1.1" group = "2" uecode = "0000100001">
<c:xml id="3" name="ceshi1.2" group = "2" uecode = "0000100002">
<c:xml id="4" name="ceshi1.1.1" group = "3" uecode = "00001000100001">
要详细代码,谢谢!如果答案满意可以再加分!
</xml> 展开
<xml>
<c:xml id="1" name="ceshi1" group = "1" uecode = "00001">
<c:xml id="2" name="ceshi1.1" group = "2" uecode = "0000100001">
<c:xml id="3" name="ceshi1.2" group = "2" uecode = "0000100002">
<c:xml id="4" name="ceshi1.1.1" group = "3" uecode = "00001000100001">
要详细代码,谢谢!如果答案满意可以再加分!
</xml> 展开
2个回答
展开全部
using System.XML;
public XmlDocument XmlDoc;
XmlDoc = new XmlDocument();
XmlDoc.Load(xmlfile) ; //xmlfile 为xml文件的绝对路径
XmlNode node = XmlDoc.SelectSingleNode("根节点的名称");
XmlNodeList nodelist = node.ChildNodes;
//写一个方法递归遍历子节点 就可以 了
public void Analysis(XmlNodeList xlist)
{
foreach(XmlNode node in xlist)
{
.................
Analysis("");
}
}
public XmlDocument XmlDoc;
XmlDoc = new XmlDocument();
XmlDoc.Load(xmlfile) ; //xmlfile 为xml文件的绝对路径
XmlNode node = XmlDoc.SelectSingleNode("根节点的名称");
XmlNodeList nodelist = node.ChildNodes;
//写一个方法递归遍历子节点 就可以 了
public void Analysis(XmlNodeList xlist)
{
foreach(XmlNode node in xlist)
{
.................
Analysis("");
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询