There seems to be no direct way of retrieving the Full Path of a node.. Well, that's as far i know.. I used to do it by performing a loop and the "ParentNode" property... I add every ParentNode (starting from the node i want to get a full Path for) and i perform a check until the
--------------------------
string nodeFullPath = <yourStartingNode>.Name;
XmlNode currentNode = <youStartingNode>;
while (currentNode.ParentNode != null)
{
nodeFullPath = currentNode.ParentNode + "/" + nodeFullPath;
currentNode = currentNode.ParentNode;
}
--------------------------
nodeFullPath will be the full Path
I havent tested this in VStudio for Syntax but the approach I've used before is something like it. So aside from the correct Syntax, that's how i used to do it.
One last thing, if the XML is well formed, there are times that you dont need to bother with full paths of Nodes but rather use relative path like "\\myNode". It will return all nodes with tag <myNode> regardless of where it is in the XmlDocument
hope this helps somehow... keep posting if theres any other way i could help
Main Topics
Browse All Topics





by: AndyfromFLPosted on 2005-11-18 at 13:48:59ID: 15323406
the SelectSingleNode() method takes an xpath as its argument and returns the first node that matches the xpath. If it returns 0 nodes, then you've found your XML document doesn't have the node. It's the closest there is to an IsExists() property.
Let me know if I can do anything else for you.
Thanks, Andy