title: XML parsing in java with xpath
body: <p>I am trying to print out some data
  so my code is</p>
  
  <pre><code> private static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
          private static final XPathFactory XPATH_FACTORY = XPathFactory.newInstance();
          public void parseXml(String urlPath) throws Exception {
              URL url = new URL(urlPath);
              URLConnection connection = url.openConnection();
              DocumentBuilder db = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder();
  
              final Document document = db.parse(connection.getInputStream());
              XPath xPathEvaluator = XPATH_FACTORY.newXPath();
              XPathExpression nameExpr = xPathEvaluator.compile("lfm/results/trackmatches/track");
              NodeList tracksinfoNodes = (NodeList) nameExpr.evaluate(document, XPathConstants.NODESET);
              for (int i = 0; i &lt; tracksinfoNodes.getLength(); i++) {
                  Node trackNameNode = tracksinfoNodes.item(i);
                  System.out.println(String.format("Track Name: %s" , trackNameNode.getTextContent()));
                  }
  
          }
  </code></pre>
  
  <p>so it will print me like this for the first loop</p>
  
  <pre><code>Track Name: 
      I Believe in You
      Neil Young
      http://www.last.fm/music/Neil+Young/_/I+Believe+in+You
      0
      90540
              http://userserve-ak.last.fm/serve/34s/65285990.png
      http://userserve-ak.last.fm/serve/64s/65285990.png
      http://userserve-ak.last.fm/serve/126/65285990.png
      http://userserve-ak.last.fm/serve/300x300/65285990.png
  </code></pre>
  
  <p>the url I am using is <a href="http://ws.audioscrobbler.com/2.0/?method=track.search&amp;track=Believe&amp;api_key=b25b959554ed76058ac220b7b2e0a026" rel="nofollow">http://ws.audioscrobbler.com/2.0/?method=track.search&amp;track=Believe&amp;api_key=b25b959554ed76058ac220b7b2e0a026</a></p>
  
  <p>so what I am trying to do is to get eveyone alone , like this</p>
  
  <pre><code>song : I Believe in You
  artist :Neil Young
  link : http://www.last.fm/music/Neil+Young/_/I+Believe+in+You
  something: 0
  views: 90540
  linkimg :    http://userserve-ak.last.fm/serve/34s/65285990.png
  ..
  ..
  </code></pre>