OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Simple xpath software request

[ Lists Home | Date Index | Thread Index ]
  • To: "Kris Thompson" <race@boulder.net>,<xml-dev@lists.xml.org>
  • Subject: RE: [xml-dev] Simple xpath software request
  • From: "Joshua Allen" <joshuaa@microsoft.com>
  • Date: Wed, 27 Feb 2002 23:54:46 -0800
  • Thread-index: AcHAEp0cEGD3ctEKRsm7Xz87VKF4MgAGjPog
  • Thread-topic: [xml-dev] Simple xpath software request

Well, there is an XSLT stylesheet that gives you the absolute XPath of
each node in a document:
http://msdn.microsoft.com/code/default.asp?url=/code/sample.asp?url=/msd
n-files/026/002/676/msdncompositedoc.xml
This is standard XSLT so could be run in Xalan.  But probably even
easier if you already have a reference to a node is to just write a
function that recursively grabs the node.Parent and concats the name and
position (which is really all the XSLT is doing).


> -----Original Message-----
> From: Kris Thompson [mailto:race@boulder.net]
> Sent: Thursday, February 28, 2002 11:59 AM
> To: xml-dev@lists.xml.org
> Subject: [xml-dev] Simple xpath software request
> 
> I must have missed it but I feel like my searching has been complete.
I
> am looking for a way, using one of the more popular parsers idealy
> Xerces, to if given a node in a document return the XPath string
> representation of that node.  Something like the following would be
nice
> 
> public static String getXPath(Document doc, Node node)
> 
>     where node is the node that I want the XPath expression on and doc
> is the document for which this node exist.
> 
> If this does not exist in any popular parsers than has anyone created
> this piece of code for which I could have?
> 
> Thanks
> 
> Kris Thompson
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS