PAW,
I can not understand what you looking for but does a portion of the code
below address answer your question?
private const String localURL =
"http://localhost/quickstart/howto/samples/Xml/QueryXmlDocumen tXPath/cs/book
s.xml";
public static void Main()
{
QueryXmlDocumen tXPathSample myQueryXmlDocum entXPathSample = new
QueryXmlDocumen tXPathSample();
myQueryXmlDocum entXPathSample. Run(localURL);
}
public void Run(String args)
{
Console.WriteLi ne("XPath Test started ...");
XPathDocument myXPathDocument = new XPathDocument(a rgs);
XPathNavigator myXPathNavigato r = myXPathDocument .CreateNavigato r();
// Get all the book prices
XPathQuery(myXP athNavigator, "descendant::bo ok/price");
// Get the ISBN of the last book
XPathQuery(myXP athNavigator, "bookstore/book[3]/@ISBN");
}
private void XPathQuery(XPat hNavigator myXPathNavigato r, String xpathexpr )
{
try
{
Console.WriteLi ne("XPath query: " + xpathexpr);
// Create a node interator to select nodes and move through them
(read-only)
XPathNodeIterat or myXPathNodeIter ator = myXPathNavigato r.Select
(xpathexpr);
while (myXPathNodeIte rator.MoveNext( ))
{
Console.WriteLi ne("<" + myXPathNodeIter ator.Current.Na me + "> "
+ myXPathNodeIter ator.Current.Va lue);
}
Console.WriteLi ne();
}
catch (Exception e)
{
Console.WriteLi ne ("Exception: {0}", e.ToString());
}
}
--------------------
From: "Paw Pedersen" <ne**@paws.dk >
Subject: Getting the xpath for a specific node in a xmldocument
Date: Sun, 31 Oct 2004 16:59:25 +0100
Lines: 6
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.181
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181
Message-ID: <OO************ **@TK2MSFTNGP09 .phx.gbl>
Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
NNTP-Posting-Host: cpe.atm2-0-1121065.0x503eb aea.arcnxx10.cu stomer.tele.dk
80.62.186.234Path:
cpmsftngxa10.ph x.gbl!TK2MSFTNG XA03.phx.gbl!TK 2MSFTNGP08.phx. gbl!TK2MSFTNGP0 9
.phx.gblXref: cpmsftngxa10.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:2835 01
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
When you are "working" on a specific node from a XmlDocument instance, is
itpossible to get the full xpath to this node?
Regards Paw
{\rtf1\ansi\ans icpg1252\deff0\ deflang1033{\fo nttbl{\f0\fnil\ fprq2\fcharset0
MS Sans Serif;}{\f1\fsw iss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2500;}\ viewkind4\uc1\p ard\f0\fs20 Cheers,\par
\par
johnKn [MS-SDK]\par
\par
\par
\par
-Please do not send email directly to this alias. This alias is for \par
newsgroup purposes only\par
\par
-This posting is provided "AS IS" with no warranties, and confers no
rights.\par
\par
-To provide additional feedback about your community experience please send
\par
e-mail to:
sd*****@microso ft.com\par
\f1\par
}