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 XML parsing 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 "XML parsing" Watch "XML parsing" New topic

XML parsing

Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
I am looking for a "generic XML parser",
The aim of that parser is,
Given any XML file, it should give me all the name/value pairs as an output.
Has any one used any of these type of parsers.. Any suggestions
Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
What exactly do you mean by name-value pairs? Are we talking about a level-1 XML document that has nodes nested only upto level-1, so that every node just has one non-node child?
Parsing an XML document involves stepping through the document and tokenizing nodes and elements. What you are describing can be easily achieved by using any standard parser like Xerces. If you haven't already, download Xerces and play with the example code.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Shreya Menon
Ranch Hand

Joined: Jul 31, 2001
Posts: 285
What I am talking about is, a parser , which can iterate through any levels and extract the Node/value pair ..
as an example
<address1>123 Daves Avenue</address1>
<address2>apt 345</address2>
So in this case extract the name value pairs as
name : Maya
address1 :.....
This is an XMl with different levels,,,,

William Barnes
Ranch Hand

Joined: Mar 16, 2001
Posts: 986

That is something which any parser does.
Here is a DOM tutorial

Please ignore post, I have no idea what I am talking about.
I agree. Here's the link:
subject: XML parsing
It's not a secret anymore!