I have an class like below and I use xSteam to convert Edge to xml.
@XStreamAlias("edge")
class Edge{
@XStreamAsAttribute
@XStreamAlias("source")
private String source;
@XStreamAsAttribute
@XStreamAlias("target")
private String target;
@XStreamAlias("data")
private Data data;
.....
}
When I set data=null, i can get
<edge source="8" target="10" />
but I want to get below when data =null
<edge source="8" target="10" ></edge>
Some one can help for this?
There is nothing you can do on the XML level, as on that level, both forms are completely identical. If you really really require one form instead of the other, you have to either provide your own XML serializer, or use the default serializer and post-process its output stream. i cannot give you more details without knowing how you currently serialize your data.