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/QueryXmlDocumentXPath/cs/book
s.xml";
public static void Main()
{
QueryXmlDocumentXPathSample myQueryXmlDocumentXPathSample = new
QueryXmlDocumentXPathSample();
myQueryXmlDocumentXPathSample.Run(localURL);
}
public void Run(String args)
{
Console.WriteLine("XPath Test started ...");
XPathDocument myXPathDocument = new XPathDocument(args);
XPathNavigator myXPathNavigator = myXPathDocument.CreateNavigator();
// Get all the book prices
XPathQuery(myXPathNavigator, "descendant::book/price");
// Get the ISBN of the last book
XPathQuery(myXPathNavigator, "bookstore/book[3]/@ISBN");
}
private void XPathQuery(XPathNavigator myXPathNavigator, String xpathexpr )
{
try
{
Console.WriteLine("XPath query: " + xpathexpr);
// Create a node interator to select nodes and move through them
(read-only)
XPathNodeIterator myXPathNodeIterator = myXPathNavigator.Select
(xpathexpr);
while (myXPathNodeIterator.MoveNext())
{
Console.WriteLine("<" + myXPathNodeIterator.Current.Name + "> "
+ myXPathNodeIterator.Current.Value);
}
Console.WriteLine();
}
catch (Exception e)
{
Console.WriteLine ("Exception: {0}", e.ToString());
}
}
--------------------
From: "Paw Pedersen" <
[email protected]>
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: <
[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
NNTP-Posting-Host: cpe.atm2-0-1121065.0x503ebaea.arcnxx10.customer.tele.dk 80.62.186.234
cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.csharp:283501
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
When you are "working" on a specific node from a XmlDocument instance, is it
possible to get the full xpath to this node?
Regards Paw
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fprq2\fcharset0
MS Sans Serif;}{\f1\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2500;}\viewkind4\uc1\pard\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: (e-mail address removed)\par
\f1\par
}