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

which xml parser suitable 4 this?

 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i have a xml like this

<ISSUES Data_26="" Data_27="-1" Data_28="-1" Data_29="-1" Data_31="-1" Data_32="-1" Data_33="-1" Data_34="29"/> .

This record is stored in database.

My question is
1.how can i retrive each node.
2.display all the record data_26's and its value

which is the best java xml parser is suitable and solve this.

Thanks
 
Clifton Craig
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by edward durai:
Hi,

i have a xml like this

<ISSUES Data_26="" Data_27="-1" Data_28="-1" Data_29="-1" Data_31="-1" Data_32="-1" Data_33="-1" Data_34="29"/> .

This record is stored in database.

My question is
1.how can i retrive each node.
2.display all the record data_26's and its value

which is the best java xml parser is suitable and solve this.

Thanks


Edward,

If I understand you correctly your data is in a DB table where each record stores a single XML element? There is no magic answer for that. What you would probably need to do is stream the records into any XML parser. In other words you would estblish a connection to the DB and then query the records into a result set and then iterate them [while(resultset.next()) write( resultset.getString("columnName") );] into an output stream that would be parsed by an XML parser. (Any parser should suffice and Java comes with Xerces by default.) It's probably a good idea to stream the data in a separate thread depending on the size of the table involved. Also depending on what you are trying to do with the data you might consider writing a SAX handler to respond to the parser events like startElement() and endElement(). More importantly I would question the idea of storing XML in this manner.

Understand that there is no table-contained-xml parser. Parsers genrally work on streams and readers or objects that can be easily represented as streams or readers like Strings. When your XML is locked into a weird format or storage you have to write custom code. Also consider the benefits of storing and parsing your data in it's current form. It's easy to get carried away and think that XML is a silver-bullet solution. You really need a clear goal as well as a good understanding on how XML processors work before you use it or else you could quickly build a poor performing or over complicated app.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic