aspose file tools*
The moose likes XML and Related Technologies and the fly likes which xml parser suitable 4 this? 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 "which xml parser suitable 4 this?" Watch "which xml parser suitable 4 this?" New topic
Author

which xml parser suitable 4 this?

Edward Durai
Ranch Hand

Joined: Oct 09, 2004
Posts: 223
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


Thank You<br />Edward
Clifton Craig
Ranch Hand

Joined: May 26, 2006
Posts: 103
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.


Holla at me...<br /><a href="http://codeforfun.wordpress.com" target="_blank" rel="nofollow">http://codeforfun.wordpress.com</a>
 
 
subject: which xml parser suitable 4 this?