954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Java and XML

Hi guys

I have a tricky XML/Java situation that I need some tips on
I have an XML file
City1City2City3City1City2City3

Firstly I need to count how many cities per country. I know I have to get the parent and child nodes and so on
Secondly I need to display these cities names per country (if code =”FRA”)'

How do I do this in Java?
Thanks in advance!

michael.ngobeni
Newbie Poster
20 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

Hi michael.ngobeni,

Have a read of the javax.xml classes in the Java API . You should look in particular at the parsers package. Another step might be the java xml tutorials on sun.com .

Anyway I hope this has given you a starting point. Post back if you need more help.

Cheers
darkagn

darkagn
Veteran Poster
1,197 posts since Aug 2007
Reputation Points: 404
Solved Threads: 200
 

yah... java's xml parsers can help you more... couple of them r, DOM, JDOM, SAX...
if u use DOM or JDOM, get the whole document parsed, then just use a method called getElementsByTagName(String Tag). This is pretty easy to do. you will have to follow factory pattern.

orko
Junior Poster
164 posts since Apr 2006
Reputation Points: 46
Solved Threads: 11
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You