84
votes

I know there are some online regex evaluators.. very useful, matching in real time. They are like web applications of RegexBuddy.

I was wondering if there is a similar thing for xPath selectors? I am just learning them and it would be valuable to me.

Is there an online tester that allows you to input XML and then an xPath selector and match (live would be better, but I doubt someone has written a JavaScript interpreter?) them?

Thanks

11 Answers 11

87
votes

I notice that the only "online" checker in the answers seems a bit clunky. It requires submission to a server, and it doesn't handle namespaces properly.

I thought I could do better, and that such a tool would be quite useful, so I made one. I realize it is slightly self-promoting to mention it here, but it does specifically answer the question, I think!

http://chris.photobooks.com/xml/default.htm

Mine can apply an xpath expression to an arbitrary XML document and display the results. It can also beautify, or pretty-print an XML document, and apply an XSLT transformation to it. All processing is done by the browser, and it should work in IE6+, Firefox, Opera, Chrome, and Safari.

Please let me know if you encounter any issues with it!

5
  • Why do I have to press refresh? It should use some AJAX magic! That, and displaying/highlighting only the matches. (Just like Rubular does for regex.)
    – ashes999
    Jan 6, 2011 at 17:08
  • 2
    Sorry, the "refresh" button does not actually refresh your browser, it merely re-executes the JavaScript rendering process. I guess I should rename it, huh? There is no AJAX because no XML is ever sent to the server at any time--it's processed 100% in JavaScript. I will add highlighting when I have time; keep in mind this is a personal project for me. Nobody pays me for this! ;) Jan 7, 2011 at 4:07
  • 1
    awesome little tool saves me having to download the xpath visualiser which seems to crash alot
    – Exitos
    Jun 22, 2011 at 10:07
  • 1
    Awesome tool. Is the source available ? Sep 28, 2011 at 8:55
  • 4
    Sure is! Right click on the page and select "View Source!" ;) There's no explicit license. I'd appreciate it if you'd consider it to be under the same creative commons license as any other StackOverflow post. The source is not exactly production quality, so caveat emptor. Oct 17, 2011 at 12:57
37
votes

This is not an online tool; instead it's a Windows app, more along the lines of RegexBuddy, but for XPath.

XPathVisualizer.

screen shot http://i29.tinypic.com/1zwp5ix.jpg

7
  • Wish I'd know about that a couple of years ago. Oct 5, 2009 at 0:15
  • General observations: A good first exercise in producing a WinForms application. Not too-advanced, with too restrictive platform requirements, and a little bit too late. The real XPathVisualizer has been around since the year 2000 with thousands of downloads each month. XPath is clearly not a good area in which to try to rediscover the wheel. Apr 24, 2010 at 19:24
  • 1
    @Dimitre Novatchev, I can understand being proud of your own project, but at least resolve that your site is flagged as malware!
    – Aardvark
    Nov 12, 2010 at 17:21
  • @Aadvark: This is not "my site". Please, propose to host the XPath Visualizer and I might consider it. :) Nov 12, 2010 at 17:30
  • @Dimitre Novatchev, I would if I could!
    – Aardvark
    Nov 12, 2010 at 18:08
28
votes

Edit: The XPath Visualizer for IE now has a new, safer home, thanks to the kindness of Lars Huttar. Also there is the XPath Visualizer for FF.

The XPath Visualizer has been available for more than 10 years and has helped thousands of people learn XPath the fun way. Available for IE and for FireFox.

The XPath Visualizer is a popular tool for learning XPath by playing with XPath expressions. Free and open source.

Allows any XPath expression to be evaluated against a given XML document and displays the results hi-lighted in the xml document (if they are node(s)) or in a separate box (if the results are atomic values).

Allows xsl:variable-s to be defined and then used in XPath expressions.

Allows xsl:key-s to be defined and then referenced by key() functions within XPath expressions.

18
  • 31
    warning, according to google the linked site contains malware: safebrowsing.clients.google.com/safebrowsing/… Dec 23, 2009 at 19:45
  • I will be considering moving the download to a safe site. Any suggestions? Apr 13, 2010 at 13:09
  • @Dimitre, Firefox version can be accessed from somewhere?
    – Flack
    Jan 7, 2011 at 3:17
  • 2
    @Dimitre. In fact I am. It really messes with me to start IE just for XPV :)
    – Flack
    Feb 3, 2011 at 7:51
  • 2
    @Flack: Yes, and thank you for helping to make this possible. Feb 27, 2011 at 22:05
17
votes

Yep! Try the XPath Checker extension for Firefox. It's a handy tool.

1
  • XPath Visualizer didn't work for me in Firefox 3.5 on Ubuntu
    – jabley
    Aug 27, 2009 at 10:31
5
votes

Here is a nice one: http://www.xpathtester.com/

2
  • Although I've only tried simple xpath expressions, so far xpathtester has worked well for me too.
    – coder_tim
    Jan 6, 2011 at 23:07
  • I've been working with it for a while and I really like it. It has a Clean interface and instead of marking the results over the XML, it generates the resulting node/list/text. Jun 17, 2011 at 14:16
2
votes

You can also use Notepad++ with it's XMLTools plugin - it has xPath evaluator

2
votes

i use this one

http://xpath.online-toolz.com/tools/xpath-editor.php

1
vote

Here is one...

XPath Query Expression Tool

1
vote

I found the following tool the most helpful.

Allans Online XPath Tester

The other tools mentioned below either required a particular browser or had some issue with loading xml or using some of the more obscure XPath expressions I was using. This tool did not.

1
  • 1
    If the tool I mentioned in my answer has such issues, please do let me know so I can fix it! Thanks! Nov 20, 2009 at 22:52
1
vote

Remove It Permanently, a firefox extension available on AMO, has such visualization functions. It would be nice if it had firebug type power for the slightly advanced adblocker.

screenshot http://i49.tinypic.com/n65a3d.jpg

1
vote

If you're on Firefox, you can use Firebug + Firefinder, which enable you to filter elements based on XPath expressions, and even post the matched code to jsbin in a snap.

Not the answer you're looking for? Browse other questions tagged or ask your own question.