private void AddNode(XmlNode inXmlNode, TreeNode inTreeNode)
{
XmlNode xNode;
TreeNode tNode;
XmlNodeList nodeList;
int i = 0;
if (inXmlNode.HasChildNodes)
{
nodeList = inXmlNode.ChildNodes;
for (i = 0; i <= (nodeList.Count - 1); i++)
{
xNode = inXmlNode.ChildNodes[i];
if (null != xNode)
{
inTreeNode.ChildNodes.Add(new TreeNode(xNode.Attributes[0].Value));
tNode = inTreeNode.ChildNodes[i];
AddNode(xNode, tNode);
}
}
}
else
{
inTreeNode.Text = inXmlNode.InnerText.ToString();
}
}
但是我没有添加父节点和子节点。经过各个网站后,我了解到这是错误
inTreeNode.Nodes.Add(new TreeNode(xNode.Attributes[0].Value));
tNode = inTreeNode.Nodes[i];
但我没有获得inTreeNode.Nodes选项。
感谢您的帮助