Results 1 to 5 of 5
- 07-04-2007, 09:15 AM #1
Senior Member
- Join Date
- Jun 2007
- Posts
- 130
- Rep Power
- 0
Parse XMLfile as String using SAX parser
Hi
I am trying to use SAX parser.
Here is the requirement
I will get the XML file as string from a third party application. Now I need to get the java objects out of this String by using SAX parser.
Sample XML string as below.
I need parse this using SAX and get the values out of it.Java Code:String xmlString="<?xml version="1.0" encoding="UTF-8"?><response><record><Id>04334</Id> <Type>A</Type><effectiveDate /><lastModifiedDate>2006-04-03 00:00:00</lastModifiedDate> <modifiedBy>GH002</modifiedBy> <associatedSisId /><risk><namedInsured> <firstName>Barney</firstName><lastName>Rubble </lastName> </namedInsured><address><street1>123 Easy Street</street1> <street2>Apartment 5</street2><city>Madras</city> <state>TN</state><zip5>55345340</zip5> <zip4>2333</zip4></address></risk></record>"
thanks
- 07-04-2007, 09:17 AM #2
Senior Member
- Join Date
- Jun 2007
- Posts
- 119
- Rep Power
- 0
SAX is not a good choice for your requirement. A better idea would be to use DOM if the String that you recieve contains more then 1 records.
However if you insist on using SAX
In brief, you will have to override the existing functions in the DefaultHandler like startelement(), characters() etc and you will have to populate your Record Object by the Values that the parser returns.
- 07-04-2007, 09:17 AM #3
Senior Member
- Join Date
- Jun 2007
- Posts
- 110
- Rep Power
- 0
Check xstream to do java to xml and xml to java. Very easy to use XStream - Two Minute Tutorial
- 02-20-2009, 07:52 AM #4
Member
- Join Date
- Feb 2009
- Posts
- 1
- Rep Power
- 0
Hi
Hi guys,
Its my first post to say HI to all of you.
- 02-22-2009, 04:31 PM #5
Member
- Join Date
- Feb 2009
- Posts
- 10
- Rep Power
- 0
JDom is also a good choice.
View, validate and edit X9.37, X9.100-180 and UCD ICL files.
http://www.digertech.com
Similar Threads
-
how to Parse int to a string variable
By raj reddy in forum Java ServletReplies: 10Last Post: 01-09-2009, 07:41 PM -
how to Parse int to a string variable (pls hlp)
By raj reddy in forum Threads and SynchronizationReplies: 5Last Post: 06-10-2008, 06:32 AM -
How to parse String effectively based on a dilimiter
By raghu408 in forum Advanced JavaReplies: 26Last Post: 04-10-2008, 10:55 PM -
SAX Parse
By bluefloyd8 in forum New To JavaReplies: 1Last Post: 01-25-2008, 03:57 PM -
How to parse in html
By paty in forum New To JavaReplies: 1Last Post: 07-24-2007, 12:29 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks