Get to know your Xpath

Posted At : March 14, 2007 4:13 PM | Posted By : Mark Drew
Related Categories: coldfusion, xml

Working with XML in ColdFusion can be fun or can be daunting sometimes. One of the things that is a gotcha for me all the time is doing XPath, even after a few minutes of googling for "Xpath Tutorial" or whatever I get bored, find the solution and then that's it.

One of the great little tools I found upon my travels is the XPath Explorer, its a nice little jar file that you can just double click and run (if you are on a Mac, God help you if you are on a PC, Windows will proably think its a banana or a Nokia package installer). Once you have it running you can load in an XML File and start creating XPaths either by entering the text or clicking on nodes.

It also comes as plugins for Eclipse and NetBeans

Very handy!

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Rob Wilkerson's Gravatar I've been using the Eclipse plugin of XPath Explorer (on Windows, no less :-) for a while now and you're right, it's useful as hell. I learned a lot, too. I never really understood XPath axes until I saw how they were populated in XPath Explorer when I selected a node. Very cool. Gotta love a tool that provides a learning experience by giving you more than you thought you needed.
# Posted By Rob Wilkerson | 3/14/07 7:22 PM
jim collins's Gravatar The XML Developer Toolbar (https://addons.mozilla.org/firefox/2897/) for FireFox and the Xpather plugin (https://addons.mozilla.org/firefox/1192/) (also for FF) are also very handy.
# Posted By jim collins | 3/15/07 12:34 AM
Andrew Powell's Gravatar I still like OxygenXML for anything XML. It prompts you, it helps you with functions, it makes you feel smart....and it's standalone and/or an Eclipse plugin.

http://www.oxygenxml.com
# Posted By Andrew Powell | 3/16/07 1:44 AM
Phil Fearon's Gravatar I was going to post a recommendation for another product
called SketchPath. But realizing this is an Apple/Eclipse area
and SketchPath is .NET based this would be pretty unfair.

Instead though, as a suggestion, I would like to see some
of the SketchPath features appear in other XPath products,
especially those with which SketchPath can't ever compete.
# Posted By Phil Fearon | 7/11/07 2:45 PM
Mark Drew's Gravatar Actually, I am doing a fair amount of Xpath work, and have been building into CFEclipse's Framworks Explorer an XPath lookup function. The thing I am having problems with is constructing relative xpath , i.e. getting the parent of this tag, or the parent's parent, rather than using the xpath from the root but from a node, something like node.xpath("../../getText()") (I mean, not really that, but you know)
I shall check it out as I can run it under parallels or VM ware...
# Posted By Mark Drew | 7/11/07 2:51 PM
Phil Fearon's Gravatar Interestingly, the first feature request I had for SketchPath was for the auto-generation of xpath relative to the context node.
SketchPath doesn't do this yet, but its high on the 'to do' list.
# Posted By Phil Fearon | 7/15/07 11:48 AM