• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Node searching with Xerces

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic