tree node from xml

  • Thread starter Thread starter juli jul
  • Start date Start date
J

juli jul

Hello,
I have such declaration in function:
tmptreenode = new TreeNode(node.Name);
but I need an attribute name and not Name ,I tried to do something like
that:
tmptreenode = new TreeNode(node.Attributes);
but it doesn't work,how can I solve this?
Thank you v. much!
 
Thanks but it's not working this way:
tmptreenode = new TreeNode(node.Attributes["name"]);

it throws a compile error:
error CS1503: Argument '1': cannot convert from
'System.Xml.XmlAttribute' to 'System.Windows.Forms.TreeView'

How to solve this? Thank you!
 
That's because an XmlNode is not the same as a TreeNode. Fill up the
treeview with the InnerText value of the XmlNode.

Example:

XmlDocument doc = new XmlDocument();
XmlNode myNode;
doc.Load(@"c:\document.xml");
myNode = doc.SelectSingleNode(<XPath query>);
treeView1.Nodes.Add(myNode.InnerText);

Gabriel Lozano-Morán
 
Could you pleas tell me which xpath query I should use ?
I am new on this xml subject.
Thanks
 
Back
Top