Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

Writing XML and Whitespace

Thread view: 
Jason Cavett - 23 Feb 2007 22:07 GMT
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
Lew - 24 Feb 2007 04:19 GMT
> 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
[quoted text clipped - 4 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.