Вот пример кода... — добавление нода в treeView в соответствии с файлом xml, но без комментариев. Не получилось...
Укажите на трабл...
private void addTreeNode(XmlNode xmlNode, TreeNode treeNode)
{
int x;
XmlNodeList xNodeList;
if (xmlNode.HasChildNodes) //The current node has children
{
xNodeList = xmlNode.ChildNodes;
for ( x = 0; x <= xNodeList.Count - 1; x++)
//обход всех дочерних
{
if (xmlNode.ChildNodes[x].NodeType != XmlNodeType.Comment)
{
xNode = xmlNode.ChildNodes[x];
TreeNode trNode = new TreeNode(xNode.Name);
// MessageBox.Show(xNode.Name);
treeNode.Nodes.Add(trNode);
if (xmlNode.ChildNodes[x].Attributes.Count > 0)
{
for (int y = 0; y <= xNode.Attributes.Count - 1; y++)
{
if (xNode.Attributes[y].NodeType != XmlNodeType.Comment)
{
TreeNode hh = new TreeNode(xNode.Attributes[y].Value);
//MessageBox.Show(hh.Text);
trNode.Nodes.Add(hh);
}
else
y++;
}
}
tNode = treeNode.Nodes[x];
addTreeNode(xNode, tNode);
}
else
{
x++;
xNode = xmlNode.ChildNodes[x];
tNode = treeNode.Nodes[x];
addTreeNode(xNode, tNode);
}
}
}
// else //No children, so add the outer xml (trimming off whitespace)
// treeNode.Text = xmlNode.OuterXml.Trim();
}