aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xpath query" Watch "xpath query" New topic
Author

xpath query

Nigel Rowe
Greenhorn

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:
id:LFPG
id:08L
id:08R
id:09L
id:09R
id:26L
id:26R
id:27L
id:27R

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

Joined: Mar 22, 2005
Posts: 39578
    
  27
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 http://sourceforge.net/projects/lantern/ can help figuring out XPath expressions. Just in case you don't already some other tool :-)


Ping & DNS - updated with new look and Ping home screen widget
Nigel Rowe
Greenhorn

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: http://aspose.com/file-tools
 
subject: xpath query
 
Similar Threads
how to generalise this code
How to Generalize the code?
below code is correct way to write the code in generic way if we receive different xml formats
Retrieve values for a complicate XML file (Java)
how to get specific root, element and node?