Reputation: 27
In the Link below is perfectly explained how to write objects into an XML-File. My Question ist, how can I beware some Attributes to be written into the XML-File?
For Example:
public class Human{
private String name;
private int age;
private DateMinutesHours birthday;
public Human(nam, ag, bir){
this.name = nam;
this.age= ag;
this.birthday= bir;
}
@XmlElement( name = "lastname")
public getName(){
return this.name;
}
@NotAnXmlElement << Do something like this exist?
public getAge(){
return this.age;
}
}
Upvotes: 1
Views: 628
Reputation: 149047
You can use the @XmlTransient
annotation on the property to exclude it from being written to XML.
If you are excluding a lot of properties then you can specify @XmlAccessorType (XmlAcceessType.NONE)
on the class. This means that only things you explicitly annotate will be converted to/from XML.
Upvotes: 1