Meaningless Drivel is fun!*
The moose likes XML and Related Technologies and the fly likes how to get the whole NodeList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "how to get the whole NodeList" Watch "how to get the whole NodeList" New topic
Author

how to get the whole NodeList

Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
<University>
<Department name="Math" ....>
<address ..>
</Department>

<Department name="History" ..>
<address ...>
</Department>

<Department ...
..
</Department>
</University>

I want to get a "NodeList" of <Department>, i.e a list of <Department>s. However, when I do

XPathAPI.selectNodelist(Document, "/root/.../University/");

It returns an "Element". How to select an entire list of <Department>s as a NodeList ?

Thanks.
Miguel Capo
Greenhorn

Joined: Oct 08, 2006
Posts: 14
I believe that the following expression should give you all the nodes that you are after


/*[name()='document']/...../*[name()='University']/*[name()='Department']
 
 
subject: how to get the whole NodeList
 
Similar Threads
help with web service to display xml file contents using netbeans
DOM API don't undestand
split an xml string using xpath?
Use a SAX Parser to split huge XML file into multiple parts, also need to keep the hierarchy intact
Reading Nested XML attributes