<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>indiWiz.com &#187; xpath</title>
	<atom:link href="http://indiwiz.com/tag/xpath/feed/" rel="self" type="application/rss+xml" />
	<link>http://indiwiz.com</link>
	<description>Subhash&#039;s Tech Log</description>
	<lastBuildDate>Wed, 03 Mar 2010 13:24:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>XPath in Java: Code Snippet</title>
		<link>http://indiwiz.com/2009/04/25/xpath-in-java-code-snippet/</link>
		<comments>http://indiwiz.com/2009/04/25/xpath-in-java-code-snippet/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 04:41:28 +0000</pubDate>
		<dc:creator>Subhash Chandran</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xpath]]></category>

		<guid isPermaLink="false">http://indiwiz.com/?p=271</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><pre class="brush: java; title: ; notranslate">
try{
    InputStream is = ...;

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(is);
    is.close();

    XPathFactory xfactory = XPathFactory.newInstance();
    XPath xpath = xfactory.newXPath();
    XPathExpression xpr = xpath.compile(&quot;/executors/executor&quot;);

    NodeList nodes = (NodeList)xpr.evaluate(doc, XPathConstants.NODESET);
    int size = nodes.getLength();
    for(int i=0; i&lt;size; i++){
        NamedNodeMap nnm = nodes.item(i).getAttributes();
        String strPath = nnm.getNamedItem(&quot;path&quot;).getNodeValue();
        String strClass = nnm.getNamedItem(&quot;class&quot;).getNodeValue();
        print(&quot;Path / Class: &quot; + strPath + &quot; / &quot; + strClass);
    }
} catch(ParserConfigurationException ex){
    print(ex.getMessage());
} catch(SAXException ex){
    print(ex.getMessage());
} catch(IOException ex){
    print(ex.getMessage());
} catch(XPathExpressionException ex){
    print(ex.getMessage());
}
</pre>
<div class="shr-publisher-271"></div><!-- Start Shareaholic LikeButtonSetBottom --><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://indiwiz.com/2009/04/25/xpath-in-java-code-snippet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

