Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML parsing

 
Shreya Menon
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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
Thanks
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Shreya Menon
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajith,
What I am talking about is, a parser , which can iterate through any levels and extract the Node/value pair ..
as an example
<example>
<name>Maya</name>
<address>
<address1>123 Daves Avenue</address1>
<address2>apt 345</address2>
<city>Campbell</city>
<state>CA</state>
<zipcode>60132</zipcode>
</address>
<Occupation>Software,/Occupation
</example>
So in this case extract the name value pairs as
name : Maya
address1 :.....
Occupation:
This is an XMl with different levels,,,,

Thanks
Maya
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is something which any parser does.
Here is a DOM tutorial
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic