Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Convert only selected Object elements to XML through Annotation?

 
Chitra Jagannathan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 436
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
XStream can do this easily.
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the use of annotation @XmlTransient.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic