Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Obtain Full Path of XML Node [Thread Next] Re: Obtain Full Path of XML NodeTo: NULL Date: 4/5/2006 12:40:00 AM > At the point in the For Next loop where objCustNode.nodeName is equal > to "Tag3", I want to know what's it's FULL path is, ie, > "//Tag1/Tag2/Tag3". If you want absolute path, you want to start with /, not // It's fairly trivial to implement a non-namespace-aware version of this, walking up the node's ancestors and building up the path. Note that at each level you need to count the number of preceeding instances of nodes with the same type and name, since what you really want is more like /Tag1[1]/Tag2[4]/Tag3[2] Properly supporting namespaces, unfortunately, is uglier, since the normal XPath syntax requires that the namespace bindings be given as prefixes but provides no syntax for declaring those prefixes. The ugly workaround is to generate something more like /child::*[localname()="Tag1" and namespace()="http://whatever"][1] for each step. An XSLT implementation of the non-namespace-aware version appeared in my DeveloperWorks article on using stylesheets to debug other stylesheets. It shouldn't be hard to implement it in any other language, and off-the-shelf implementations probably do exist though I've had no reason to go looking for one recently. I don't use VB so I can't give you any specific advice for that environment. -- () ASCII Ribbon Campaign | Joe Kesselman /\ Stamp out HTML e-mail! | System architexture and kinetic poetry | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
