swirl
Home Software Blog Wallpapers Webtools
XPath utility

homeHome
Software listSoftware List

Delicious Bookmark this on Delicious

XPath utility

zip file Download file (23 KB) [Downloaded 506 times]

Features

  • Look for matches in your xml content in one or several files
  • Select nodes using xpath and display them
  • Run additional xpaths on matched nodes to display multiple values

Usage help

  • Download the xpath.zip file, unzip it to any folder.
  • Open a command prompt window and view the help using "xpath -help"

Here are some examples which use the XML data below to explain how to use the utility:

<?xml version="1.0" encoding="utf-8" ?>
<books>
	<book title="2001 space odyssey" price="40">
		<authors>
			<author>Arthur C. Clarke</author>
		</authors>
	</book>
	<book title="FREAKONOMICS - A Rogue Economist Explores the Hidden Side of Everything" price="10">
		<authors>
			<author>Steven D. Levitt</author>
			<author>Stephen J. Dubner</author>
		</authors>
	</book>
	<book title="I, Robot" price="35">
		<authors>
			<author>Isaac Asimov</author>
		</authors>
	</book>
</books>

1. Search for matches in a file which match a given xpath:

xpath -file books.xml -query "books/book/authors/author[text() = 'Arthur C. Clarke']" -select InnerText

Outputs:

Sample1 output

2. Search for matches in a file which match a given xpath and display multiple values:

xpath -file books.xml -query "books/book/authors/author[text()='Arthur C. Clarke']" -select Custom -custom "parent::authors/parent::book/@title;parent::authors/parent::book/@price" -errors

Outputs:

Sample2 output

3. Look for matches in all xml files under c:\temp\ and its subfolder having a particular condition:

xpath -file books.xml -query "books/book[@price > 30]" -select Match -errors

Outputs:

Sample3 output

Pre-requisite software