aspose file tools*
The moose likes XML and Related Technologies and the fly likes how to use XpathAPI to select a list of Node ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "how to use XpathAPI to select a list of Node ?" Watch "how to use XpathAPI to select a list of Node ?" New topic
Author

how to use XpathAPI to select a list of Node ?

Raj Ohadi
Ranch Hand

Joined: Jun 30, 2006
Posts: 316
<Department>
<Name>Chemistry</Name>
<Address>1 Main Campus Rd</Address>
<Phone>1-800-200-3909</Phone>
...
...
</Department>


What I need is to get the String content for "Name", "Address", "Phone", etc. One way is to
****
// get "Department" element first, let's assume it is done and passed as "departmentElement" then
XpathAPI.selectSingleNode(departmentElement, "./Name");
XpathAPI.selectSingleNode(departmentElement, "./Phone");
...
..
****
The problem is I have to do Xpath for many times if I have *many* sub elements.

Is there a way I can get all the sub elements at one (use XpathAPI once), and then get string values for "Name", "Address" easily ?

Thanks.
Sameer Jamal
Ranch Hand

Joined: Feb 16, 2001
Posts: 1870
I think './*' should work.
[ October 19, 2006: Message edited by: Sameer Jamal ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use XpathAPI to select a list of Node ?
 
Similar Threads
KSoap2 question, please reply
evaluating XPath predicates - question
need to break a huge xml into smaller groups one by one without loading the whole xml
DOM and XPath Problem
Parsing an XML Document containing Namesapces using XPath and Xalan