File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Node searching with Xerces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Node searching with Xerces" Watch "Node searching with Xerces" New topic

Node searching with Xerces

Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
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

Joined: Aug 31, 2008
Posts: 47
Have a look at the package javax.xml.xpath

Author of VFSJFileChooser and XPontus XML Editor
Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
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
I agree. Here's the link:
subject: Node searching with Xerces
jQuery in Action, 3rd edition