Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Other Open Source Projects and the fly likes Excel from xml String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Excel from xml String" Watch "Excel from xml String" New topic

Excel from xml String

Shiva Shankar
Ranch Hand

Joined: Dec 07, 2006
Posts: 31

We are calling SOAP Webservice which will execute DB query and returns the result as XML data.

Now XML data is stored in java.lang.String.

Can any one help me to provide sample code to generate excel file from the String which contains XML data.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
You can use the SAX or DOM APIs to extract the data from the XML string, and then use the Apache POI library to create an Excel file.
Shiva Shankar
Ranch Hand

Joined: Dec 07, 2006
Posts: 31
My application is getting very large response around 3-4 MB sometimes.
Is it feasible to use SAX or DOM parser?
Martijn Verburg

Joined: Jun 24, 2003
Posts: 3275

That depends on what you're trying to achieve! DOM parsers are typically used when you processing needs to know about the relationships of your XML structure (e.g. You have to navigate parent/child relationships). I tend to use SAX when I'm going for a 'smash and grab' operation, e.g. Just getting all of nodes called <foobar> and seeing value value they hold

Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
I agree. Here's the link:
subject: Excel from xml String
It's not a secret anymore!