You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Nick de Graeve <ni...@telenet.be> on 2009/09/25 10:13:00 UTC

toString() differs from save()

When I save my XMLBean to disk I get a slightly different result from when I do a toString() or xmlText().
The formatting and contents are the same but the file on disk starts with

<?xml version="1.0" encoding="UTF-8"?>

while the string does not.

How can I make sure both are exactly the same?



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org


Re: toString() differs from save()

Posted by Jacob Danner <ja...@gmail.com>.
This is by design, take a peek at the javadoc.
http://xmlbeans.apache.org/docs/2.4.0/reference/org/apache/xmlbeans/XmlTokenSource.html#xmlText(org.apache.xmlbeans.XmlOptions)
xmlText

String <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html>
*xmlText*(XmlOptions
<http://xmlbeans.apache.org/docs/2.4.0/reference/org/apache/xmlbeans/XmlOptions.html>
options)

Just like xmlText() but with options. Options map may be null.

Note that this method does not produce XML with the XML declaration,
including the encoding information. To save the XML declaration with the
XML, see save(OutputStream)<http://xmlbeans.apache.org/docs/2.4.0/reference/org/apache/xmlbeans/XmlTokenSource.html#save%28java.io.OutputStream%29>or
save(OutputStream,
XmlOptions)<http://xmlbeans.apache.org/docs/2.4.0/reference/org/apache/xmlbeans/XmlTokenSource.html#save%28java.io.OutputStream,%20org.apache.xmlbeans.XmlOptions%29>.

HTH,
-jacobd

On Fri, Sep 25, 2009 at 1:13 AM, Nick de Graeve <ni...@telenet.be>wrote:

> When I save my XMLBean to disk I get a slightly different result from when
> I do a toString() or xmlText().
> The formatting and contents are the same but the file on disk starts with
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> while the string does not.
>
> How can I make sure both are exactly the same?
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org
>
>