Search code examples
xmlxstream

Self closing tags with XStream?


Is there a way to get XStream to generate self closing elements?

E.g.

<foo/>

instead of

<foo></foo>

Solution

  • There doesn't seem to be an explicit way to do this, since it's not supposed to matter to downstream XML processors.

    You might take a look at the source for the PrettyPrintWriter class, which is probably what it's using.