Jump to content



Photo

Using Java to take in a XML file

java xml parse

  • Please log in to reply
2 replies to this topic

#1 timsweb

timsweb

    Neowinian Senior

  • Joined: 19-February 04
  • Location: UK

Posted 11 July 2012 - 18:55

Hey,

I was wondering how I could use Java to take in a XML file and put the data in a object? and write to a XML file?

Thanks, Tim


#2 kjordan2001

kjordan2001

    Mystery Solver

  • Tech Issues Solved: 1
  • Joined: 27-May 02

Posted 12 July 2012 - 01:48

For serializing objects, you might want to take a look at XStream: http://xstream.codehaus.org/

If external libraries aren't an option, you can use the built-in java classes for XML parsing:
http://www.mkyong.co...ava-dom-parser/
http://www.mkyong.co...ava-sax-parser/

You'll have to do any type conversions for numbers and such for the values inside the XML nodes this way though.

#3 OP timsweb

timsweb

    Neowinian Senior

  • Joined: 19-February 04
  • Location: UK

Posted 22 July 2012 - 13:02

Exactly what I was looking for, thanks kjordan2001



Click here to login or here to register to remove this ad, it's free!