0

I have an xml file which I want to read and parse it into POJO.

I am using XStream for this.

I am not able to send the file as an input to the code for parsing(file is on my local drive).

How to read the xml file and parse it using fromXML() method ?

I would be gratefull if someone can give example for sending xml file as input and parsing it to POJO and printing it on the screen

Thanks...

shiny
  • 43
  • 1
  • 11
  • What overloads of fromXML() have you tried? Different fromXML() overloads can take File, InputStream or Reader. You can represent your file as any of those. – Olaf Aug 06 '12 at 14:34
  • 2
    HAve you looked into using JAXB? – ChadNC Aug 06 '12 at 14:46
  • @Olaf : I have tried almost all overloads of fromXML() – shiny Aug 07 '12 at 07:01
  • @ChadNC : In our appln I am suppose to use XStream. So even though I have looked into XStream, I will be using XStream – shiny Aug 07 '12 at 07:03
  • @shiny: When you used fromXML(File), what was the specific error that you've got? – Olaf Aug 07 '12 at 12:44
  • @Olaf: I think it was Content cannot have prolong.. something of this sort... Now I have used StringBuffer and inserted entire xml in it. – shiny Aug 08 '12 at 08:33
  • Now the problem that I am facing is unmarshalling multiple enteries to POJO. Like I have abcxyz – shiny Aug 08 '12 at 08:35

1 Answers1

0

Based on the provided comments, I can better understand the problem you are facing. I believe the answer you are looking for is implicit collections. Check out the XStream tutorial on aliasing: http://x-stream.github.io/alias-tutorial.html .

facundofarias
  • 2,973
  • 28
  • 27
Olaf
  • 6,249
  • 1
  • 19
  • 37