XML in Java, how to show an @XmlElement Atribute Java Bean Null as a Empty Valuein XML (Solution Found)
<p>im working in a project. A have a Java Bean with some properties. I mark each attribute with the Tag @XmlElement, like this:</p>

<pre><code>@XmlElement(name="id", nillable = true)
private String test;
</code></pre>

<p>I put this "nillable", it shows me the tag, even when is null true but it shows me a message in xml when is null </p>

<pre><code>&lt;id xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/&gt;
</code></pre>

<p>But when it's null i want to show a empty value with the tags only, like this</p>

<pre><code>&lt;id&gt;&lt;/id&gt;
</code></pre>

<p>And i don't know how to do this. I searched but i didn't found how, thats why i'm asking.</p>

<p>And more 1 Thing, can i generate XML that's with no attributes ? Because im My XML i have to generate aloot blank tags, with nothing inside, just the tags and i dont wanna make aloot of atributes if i wont use this just to show the Tag</p>

<p>Thanks !</p>

<p>The imports and some config that i using</p>

<pre><code>import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="test")
</code></pre>

<p>---------Solution----------</p>

<p>Hi, guys, i found a solution.
I Want to share if someone got stuck in same problem.
Ou declare the property of the Class as empty, something like
String personName = "";</p>

<p>Them you don't need to create the Getters and Setters if you wont change this value and just want the tag appers in XML but empty.</p>

<p>Note: For this work you have to use the 
@XmlAccessorType(XmlAccessType.FIELD) in your class.
Thanks to all.
Bye</p>