Thursday, July 7, 2011

Automatic xpath generation

Another feature xmltoolbox has is the ability to automaticly generate xpaths. The tool can be found here xmltoolbox.appspot.com/index.html

If you have an xml that looks like this.


<root>
  <firstchild>content</firstchild>
  <list>
    <listitem>first list item</listitem>
    <listitem>second list item</listitem>
  </list>
</root>

Then you click on the element, attribute or text you want the xpath generated for. For instance if you click on content you will get this xpath.

/root/firstchild/text()

If you click on the first and second list item you will get theese values.
/root/list/listitem[1]/text()
/root/list/listitem[2]/text()

No comments:

Post a Comment