This is strange since I do that regularly.
Here is the code that I use to parse and to serialize. Try to compare
the options I use with yours.
Sebastien
Serialization :
OutputFormat outputFormat = new OutputFormat(document);
outputFormat.setPreserveSpace(false);
outputFormat.setIndenting(true);
I just
tried this, but it doesn't help.
-Original Message-From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]Sent: Wednesday, March 28, 2001
11:05 AMTo: [EMAIL PROTECTED]Subject: Re:
Output DOM to a String in a more readable formatYou may
not use outputformat correctly for
You may not use outputformat correctly for the second serialization. You
have to set these two properties :
outputFormat.setPreserveSpace(false);
outputFormat.setIndenting(true);
If not, the indentation is not done and you will get more or less what
you had in the initial string (with
Thanks
for your replies guys. Using XMLSerializer and OutputFormat, I am able to
generate well formated XML String. However if later on I am trying to
re-generate the DOM from the String using the following
method:
Document
doc = builder.parse( new InputSource( new StringReader(x
Take care that there was a kind of bug in the serializer. There was no
indentation nor cariage return around comments. Thus, if your file has
many comments, it could even be serialized on a single line.
This problem has been fixed recently (last week I think) and you
have to download the latest s
tant, Rajeswari
[mailto:[EMAIL PROTECTED]Sent: Tuesday, March 27,
2001 12:32 PMTo: '[EMAIL PROTECTED]'Subject:
RE: Output DOM to a String in a more readable format
Create OutputFormat using the following constructor
which has an option for indenting the output.
Create OutputFormat using the following constructor
which has an option for indenting the output.
OutputFormat(Document doc,
java.lang.String encoding,
boolean indenting)
-Original Message-From: Lei Chen
[mailto:[EMAIL PROTECTED]Sent: Tuesday, March 27, 2001 3:25