Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Node searching with Xerces

 
Shashank Agarwal
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to find a node in my XML document, but it should be within a specific parent. Here's what the XML looks like -

Here, "Methods" is the main title, but "Western Blotting" is the subtitle. If I just want to capture the titles, then I'd want to look for "article/sec/title", but if I want only subtitles, I'd look for "articles/sec/sec/title". I'm using xerces. Here's what I've got -



But this gets all the titles (including sub-titles). I tried replacing "title" with "article/sec/title" and "article::sec::title", but that just returns no nodes. Searched online, but didn't find anything.
 
Yves Zoundi
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the package javax.xml.xpath
 
Shashank Agarwal
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Yves!!! It worked.

Just for anyone who has the same problem in future, here's the code that I used -


Found the code off http://www.ibm.com/developerworks/library/x-javaxpathapi.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic