wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes How to Convert automaticaly from XML to Java Object and Vice versa ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to Convert automaticaly from XML to Java Object and Vice versa ?" Watch "How to Convert automaticaly from XML to Java Object and Vice versa ?" New topic
Author

How to Convert automaticaly from XML to Java Object and Vice versa ?

Marat Matosov
Greenhorn

Joined: Sep 25, 2002
Posts: 6
Hello To All !
I am a XML beginner and I need to find a some API to transform
an XML data (fully String presented document like this :
- <Listing>
<Name>Mary Smith</Name>
- <Address>
<StreetNum>888</StreetNum>
<StreetName>Broadway</StreetName>
<City>Somewhere</City>
<State>FL</State>
<Zip>87654</Zip>
- <PhoneNumber>
<AreaCode>222</AreaCode>
<Exchange>333</Exchange>
<Number>4444</Number>
</PhoneNumber>
</Address>
</Listing>
- <Listing>
) represented in java.lang.String to Element and vice versa .
I've tried some advantageous way using the JAXP compatible Xercer parser API's .
(http://www.ibiblio.org/xml/books/xmljava/chapters/ch13s02.html#IndentedFibonacci.java)
It's a good way to parse Element to String via XMLSerializer ..
But my question is : Is some API's exist to MAP somehow existing Java Object (Class) to Defined XML structure and vice versa for Automatical parsing from XML to Java Object and From Java Object to XML ?
If you know what I am talking about please respond to mmarat@hotmail.com .

Thank you ,

Marat
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
There are several APIs for doing this. Sun and the Java Community Process are developing one called JAXB - Java Api for Xml Binding. See:
http://java.sun.com/xml/jaxb/
I have been experimenting with it and found it pretty easy and fast.
Another API is called CASTOR - I have not used it.
Bill
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
The know open source products: caster / JSX. The JSX is gnu licensed, if you use it, you need make your product open source or pay for it. Do a google search, they are easy to be found.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to Convert automaticaly from XML to Java Object and Vice versa ?
 
Similar Threads
XML Node Parsing Problem , when Node owns NodeList using Xercer , HELP !!!!
Inhertiting complex type in XML Schema
Inhertiting complex type in XML Schema
Doubt on JAXB example
Confused in XML Schema.