This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 732
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: 732
Hello,

Can anybody help me?

Best regards
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 394
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: 499
    
    3
>"//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().
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How can I break XPath child node records
 
Similar Threads
XPath Question
Parsing XML file using Xpath in jdk1.4
Reading Nested XML attributes
below code is correct way to write the code in generic way if we receive different xml formats
How to Generalize the code?