Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Writing XML and Whitespace

Reply
Thread Tools

Writing XML and Whitespace

 
 
Jason Cavett
Guest
Posts: n/a
 
      02-23-2007
I've done some research and figured out how to fix my problem, but now
I'm wondering why this whitespace problem happens.

When I use the following code...

OutputFormat format = new OutputFormat(document);
format.setIndenting(false);
XMLSerializer serializer = new XMLSerializer(new
FileOutputStream(file), format);
serializer.serialize(document);

....to write an XML document (org.w3c.dom.Document), the resulting
output is fine. But, if set indenting to true (to make the XML look
pretty), I get all these weird block characters in the resulting txt
file. The file still opens up okay in my browser, but my application
can't seem to handle it because the reader wants to treat those block
characters as nodes.

Any idea why this happens? Is there a way to fix this and still allow
indenting in my document?


Thanks

 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      02-24-2007
Jason Cavett wrote:
> output is fine. But, if set indenting to true (to make the XML look
> pretty), I get all these weird block characters in the resulting txt
> file. The file still opens up okay in my browser, but my application
> can't seem to handle it because the reader wants to treat those block
> characters as nodes.
>
> Any idea why this happens? Is there a way to fix this and still allow
> indenting in my document?


Is it literally every other character that appears to be a "block" in your
"reader"?

By the way, what browser? What reader? What application? How are you
confirming in the .txt file what is in there?

Does the viewer that you use to review the text file understand UTF-8 encoding?

Writers and readers with different character encodings cause symptoms that
some people might describe similarly, but without more precise information it
is difficult to be certain if that is relevant.

- Lew
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Splitting text at whitespace but keeping the whitespace in thereturned list MRAB Python 3 01-26-2010 11:36 PM
Structure using whitespace vs logical whitespace cmdrrickhunter@yaho.com Python 10 12-16-2008 03:51 PM
xml.parsers.expat loading xml into a dict and whitespace kaens Python 6 05-23-2007 11:44 AM
Re: xml.parsers.expat loading xml into a dict and whitespace kaens Python 0 05-23-2007 06:15 AM
Whitespace where I don't want whitespace! Oli Filth HTML 9 01-17-2005 08:47 PM



Advertisments