Hello Heath, I know this thread over 5 years old and I hope you're still subscribing to it. I'm also trying to expand the path to a specific node in a treeview (i.e. a node that has just been added by a user). I almost understand your code example. However my question is, where did you get the TreeNodeCollection for the "Nodes" parameter in the initial FindPathHelper call (within the FindPath function)? I don't see it declared anywhere. Thanks, Sacha
korell
Posts
-
Help with setting and expanding nodes in treeview -
How to get XPath to XML node from treeview node?Thanks Didi, That's almost exactly what I did, except I store the entire XPath in the Name property of the treenode. Every time a treenode gets created, I call a function GetXPath(tvwNode, xmlNode) that stores the XPath for that node in the treeview node Name property. Sacha
-
How to get XPath to XML node from treeview node?I have a treeview that was populated by using a recursive function to add nodes from an XML document to the tree. I want the user to be able to right-click on any node and get the xpath to that node (similar to the "Copy XPath" function in Altova XMLSpy.) At first I thought I could just use the XMLSpy API and call that function, but apparently it's not available. Has anybody written a "GetXPath" function, or have an idea how to approach this problem? By the way, using TreeView.SelectedNode.FullPath is not going to work in this case since it does not return a node index. For the example below, Treeview.SelectedNode.FullPath would simply return "/Report/Section/Content/Item/Title/Item", but I need "/Report/Section/Content/Item[3]/Title/Item" <Report> <Section> <Title> <Item>Header</Item> </Title> <Content> <Item> <Title> <Item>Title 1</Item> </Title> </Item> <Item> <Title> <Item>Title 2</Item> </Title> </Item> <Item> <Title> &n