![1]: http://i.imgur.com/WcyqFpb.png “Xml File Sample”
Hi guys, I try to parse xml library using XPath. The following expression returns me the name of the track (What’s up)
String exp = "//dict/dict/key[. = 'Name']/following-sibling::*[1]/text()";
String name = (String) this.xpath.compile(exp).evaluate(this.doc, XPathConstants.STRING);
How can I loop through dict to get all track name,artist,album, I tried to do something like this but then I was stuck.
String baseExp = "//dict/dict"; // returns me 2084 node (the number of songs I have in my library)
NodeList nodeList = (NodeList) this.xpath.compile(baseExp).evaluate(this.doc, XPathConstants.NODESET);
for(int i=0;i<nodeList.getLength();i++) {
// need do something here?
}
Advertisements