I am using the XStream library (1.4.10) and the Dom4jDriver to generate xml content from a Java object. The problem is that it appends a new line at the beginning of the content. Anyway to turn this off?
Dom4JDriver dom4JDriver = new Dom4JDriver();
dom4JDriver.getOutputFormat().setSuppressDeclaration(true);
XStream xStream = new XStream(dom4JDriver);
xStream.processAnnotations(MyClass.class);
String myContent = xStream.toXML(myClassInstance); //extra '\n' appended at the start of the string
MyClass.class:
@XStreamAlias("myClass")
public class MyClass{
private String something;
private String somethingElse;
...........
Generated xml:
\n<myClass>\n <something>blabla</something>\n......
I know that I can just use myContent.subString(...) to get rid of the first character, but it doesnt seem so clean to me. I am also doing this for a lot of operations so I would rather not have that line to begin with for performance's sake. Any advise? Thank you :)
Have you tried DomDriver in place of Dom4JDriver?