-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Need XML elements marshalling / unmarshalling example code..
PostPosted: Wed May 12, 2010 7:36 pm 
Newbie

Joined: Tue Feb 16, 2010 6:57 pm
Posts: 17
Using Spring 3.x, Hibernate 3.x and MySQL, I need to create an XML formatted response to send from Server to Client and be able to decode an XML formatted request coming in to the Server from the client.

I want to use POJO mapping, @XmlRootElement, @XMLElement, JAXB marshalling and unmarshalling to do this. Can someone point me to some sample code that I can use as a template to see how this is done?

Looking forward to any info.

Many Thanks...Mimi


Top
 Profile  
 
 Post subject: Re: Need XML elements marshalling / unmarshalling example code..
PostPosted: Wed May 12, 2010 11:20 pm 
Regular
Regular

Joined: Tue May 11, 2010 5:50 pm
Posts: 54
Location: Norman, Ok, U.S.A
JAXB is very simple and easy to use.

here is an example

Code:
@XmlRootElement(name="myRootElement")
@XmlAccessorType(XmlAccessType.FIELD|NONE)
public class MyClass{

    @XmlElement(name="myField1Node")
     private String field1;
     @XmlElememt(name="myField2Node")
     private String field2;

    getters/setters.....

JAXBContext context = JAXBContext.newInstance(MyClass.getClass()));
Unmarshaller unMarshaller = context.createUnmarshaller()
Marshaller marshaller = context.createMarshaller()

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.