title: How to read XML using XPath in Java
body: <p>I want to read XML data using XPath in Java, so for the information I have gathered I am not able to parse XML according to my requirement.</p>
  
  <p>here is what I want to do:</p>
  
  <p><strong>Get XML file from online via its URL, then use XPath to parse it, I want to create two methods in it. One is in which I enter a specific node attribute id, and I get all the child nodes as result, and second is suppose I just want to get a specific child node value only</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;howto&gt;
    &lt;topic name="Java"&gt;
        &lt;url&gt;http://www.rgagnonjavahowto.htm&lt;/url&gt;
    &lt;car&gt;taxi&lt;/car&gt;
    &lt;/topic&gt;
    &lt;topic name="PowerBuilder"&gt;
         &lt;url&gt;http://www.rgagnon/pbhowto.htm&lt;/url&gt;
         &lt;url&gt;http://www.rgagnon/pbhowtonew.htm&lt;/url&gt;
    &lt;/topic&gt;
    &lt;topic name="Javascript"&gt;
          &lt;url&gt;http://www.rgagnon/jshowto.htm&lt;/url&gt;
    &lt;/topic&gt;
   &lt;topic name="VBScript"&gt;
         &lt;url&gt;http://www.rgagnon/vbshowto.htm&lt;/url&gt;
   &lt;/topic&gt;
   &lt;/howto&gt;
  </code></pre>
  
  <p>In above example I want to read all the elements if I search via @name and also one function in which I just want the url from @name 'Javascript' only return one node element.</p>