This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes XML and Related Technologies and the fly likes Convert only selected Object elements to XML through Annotation? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Convert only selected Object elements to XML through Annotation?" Watch "Convert only selected Object elements to XML through Annotation?" New topic
Author

Convert only selected Object elements to XML through Annotation?

Chitra Jagannathan
Greenhorn

Joined: Apr 21, 2009
Posts: 8
Can we Convert only selected Object elements to XML through Annotation?

Ex:
Person
- name
- empId
- address
- city
- profession

I want to convert Person object to XML through annotation with only empId and profession.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
Personally, if I want a custom serialization of an object I just build a string in the correct XML format with the desired values.

Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
XStream can do this easily.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 510
    
    3
Check out the use of annotation @XmlTransient.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert only selected Object elements to XML through Annotation?