tags:

views:

183

answers:

6

I wonder if there is a Xpath equivalent to http://gskinner.com/RegExr/ for Regex?

In this way you could just type an xpath query and it will show you what elements were selected.

I haven't found anything as simple as http://gskinner.com/RegExr/ yet.

+2  A: 

Here is one I like using.

Paste in your XML, type your XPath expression and see what was selected.

It also has a pretty print options and an XSLT transformation option.

Oded
Doesnt work with safari :)
never_had_a_name
+2  A: 

Xselerator has an "XPath Query Analyser". Also it's a good IDE wich allow the use of many processors and viewers.

Alejandro
+3  A: 

Look up the XPath Visualizer -- has versions for IE and for Mozilla/Firefox

This is a tool I wrote in 2000. Since then it has had many thousands of downloads and there hasn't been even a single unhappy user.

Warning: topxml.com has a trojan -- don't click on the above links unless you have a good malware protector.

Here are some screenshots from the tool, showing:

  1. The inline- hilighting of the selected nodes

  2. Evaluating every possible XPath expression, not only those that select nodes.

  3. Defining and using variables in the XPath expressions.

  4. Remembering all used XPath expressions.

  5. Defining and using XSLT keys.


alt text


alt text


alt text


alt text


alt text


alt text


alt text


alt text


alt text


alt text


alt text


alt text


alt text


alt text

Dimitre Novatchev
How can i download it if it has a trojan? =)
never_had_a_name
btw, im using Mac, so i cant use Xpath Visualizer?
never_had_a_name
@ajsie: I don't think it will work on a Mac. It uses a browser and MSXML3. Maybe the version for Firefox will work on a Mac (haven't ever had a mac -- haven't ever tried).As for how to download, if you send me email (my SO userid (dnovatchev) on the Google's mail), I will send you the files as attachment. Otherwise what I do is: 1. I download the file. 2. I clear the trojan with my anti-malware tool. I would be glad to give it for distribution on a more reliable host.
Dimitre Novatchev
@dimitre. thanks. i have installed xpather on Firefox and it worked great.
never_had_a_name
@ajsie: I had a look at XPather and it seems to be very different, and in my opinion not so powerful and expressive as the XPath Visualizer. I have included in my answer a few screenshots from the XPath Visualizer, showing some of its features. So, you may judge for yourself. :)
Dimitre Novatchev
+3  A: 

Some XPath visualisers

XPath applications

  • XPath Visualizer -- Windows application, open source, requires .NET v. 3.5. Results shown as highlighted code. This is probably not the same tool that Dimitre already suggested although they have same name.
  • AquaPath -- Macintosh application, open source. Results shown as highlighted code.

XML editors with somehow similar functionality

  • XMLMate -- Plugin to Macintosh application TextMate, open source.
  • Xmplify -- Macintosh application, still in beta.
  • Editix -- Cross platform application (Windows, Macintosh, Linux), requires Java 5.x or newer

Online services

  • Allans Online XPath Tester -- XML document can be pasted to textarea or referenced via URL. As a result prints the document contents with selected nodes highlighted below the textarea
  • XPath Query Expression Tool -- XML input via textarea. Doesn't actually highlight selection but prints the text content of selected elements
  • Martijn van Beek's XPath Analyser -- XML input via textarea, requires Flash, open source. This is a new project: released 2010-08-24 so I'm guessing it will probably go through some updates or changes in the near future.

Browser extensions (or something)

  • XPath Checker -- Firefox extension. Shows an XPath query window instead of code highlight.
  • XPather -- Firefox extension, requires DOM inspector extension.
  • XPath tester -- Requires Microsoft Silverlight
jasso
[1] The Oxygen XML editor <http://www.oxygenxml.com/> also does interactive xpath evaluation.[2] There is a perl xpath command line script that comes with the Perl XPath module that will evaluate an xpath on a file and display the results.
Steven D. Majewski
+1  A: 

I've got something like that on my xml tools page: http://www.flynn1179.net/xml/

Flynn1179
A: 

Hi,

I have also made a online XPath evaluator. It supports XPath 2.0. It is available at http://www.xmltools.dk and here is a few screenshots:

XPath 2.0 evaluations which renders a sequence of numbers:

alt text

And, elements and attributes are marked when searched for:

alt text

lasseespeholt