File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes xpath query 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 "xpath query" Watch "xpath query" New topic

xpath query

Nigel Rowe

Joined: Jun 17, 2012
Posts: 6
Hello all,
I have xml files that look like this:

I have to insert this data into two tables, airport and runway based on nodes from <ICAO id="****"> and nodes from <Runway id="***">
I am up to here for the moment:

Which returns:

Any ideas on what to do next? Can I do it with one xpath query?
Any propositions welcome!
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41151
Not sure, but do you really need it to be one query? It seems that would be two different data sets (for which you probably need to use different code for the DB insert), so maybe they shouldn't be treated the same. An outer loop dealing with airports, and an inner loop dealing with runways -each with its own XPath expression- would seem to be a natural approach.

(By the way, a tool like can help figuring out XPath expressions. Just in case you don't already some other tool :-)

Ping & DNS - my free Android networking tools app
Nigel Rowe

Joined: Jun 17, 2012
Posts: 6
Hello Ulf,
First of all, please accept my apologies for not replying earlier. For some reason, I could not even connect to the ranch, and then, when I could, I could not reply to any of the posts.

Your reply is perfectly correct. That's what I did in the end, I couldn't afford to waste anymore time on the thing, and as it was a one off shot it didn't realy matter. Thanks very much for your help.
I agree. Here's the link:
subject: xpath query
Similar Threads
how to generalise this code
Retrieve values for a complicate XML file (Java)
below code is correct way to write the code in generic way if we receive different xml formats
how to get specific root, element and node?
How to Generalize the code?