On Mon, 20 Nov 2006 07:27:02 -0800, Sharon wrote:
Dimitre, thanks for your reply.
After looking at the link you have posted, I'm afraid I don't understand it.
In this link page I see only XML file. But I need to find the node XML path
by code, like the C# using any standard parser.
------
Thanks
Sharon
The problem you have is that it is very complex to identify the index of
the elements in a node path, and that's what the example Dimittre posted is
doing.
An XmlNode has a ParentNode method, so you can just walk back up the tree,
reading the name of each node, and that might give you something like
System/Parameters/T1/T2/T3/L3.1
The problem is that you also need the index of items that are part of a
repeating node:
System/Parameters/T1/T2/T3/L3.1[3]
Your example says 'doc.SelectSingleNode', but there are 5 nodes in your
document, so walking back up the tree will give you a simple XPath to the
first node (if there are no repeating elements further up the tree), but
this is a far from suitable solution.
Why do you need the XPath expression? What is it being used for?
Cheers,
Gadget