File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes How can I break XPath child node records 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 "How can I break XPath child node records" Watch "How can I break XPath child node records" New topic
Author

How can I break XPath child node records

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 726
Hello,



Here is my code:


The output is very correct like this:
=======================================
Bogomolets National Medical University
Masters degree
June 2007
O.O. Bogomolets National Medical University
(MBBS)
June 2004
===============================================

I want to read ><University><Degree><Year> in three different variables to insert them in 3 different columns of the database but when am reading like:

then its output is showing 2 existing universities whereas I need two or all universities by iterating the records:
Bogomolets National Medical University
O.O. Bogomolets National Medical University

How can I read each university/degree/year in 3 different variables to insert each record in seprate columns of database?

Best regards
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 726
Hello,

Can anybody help me?

Best regards
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 381
Here is 1 way I do:

1. I would use expression //EducationSplit to get a NodeList of EducationSplit
2. I loop thru a EducationSplit NodeList and for each Node
I would use expression University to get the value of University
I would use expression Degree to get the value of Degree
I would use expression Year to get the value of Year



g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 464
    
    2
>"//descendant::EducationSplit/*/text()"
This is akin to a monster. // is already a short-hand of descendant-or-self axis starting from the root. If it is meant for anything, it should be written as //EducationSplit/*/text().
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I break XPath child node records
 
Similar Threads
XPath Question
Reading Nested XML attributes
Parsing XML file using Xpath in jdk1.4
How to Generalize the code?
below code is correct way to write the code in generic way if we receive different xml formats