[jdom-interest] Extra newlines removing

Aleksey Nikolayev admiralspb at yahoo.com
Mon May 21 17:19:52 PDT 2001


Hello, All

This is the situation: I have created XML with JDom
and used XMLOutputter to write it to the file with
'tabs' and 'newlines' to make it look readable for the
user.

Next time my program reads the same XML (of course
parsing all those 'tabs' and 'newlines' as Elements or
something like that.

Then I modify some elements/attributes and write it
back. Vioala! I have double 'newlines' and 'tabs
inserted. 

You say - use default XMLOutputter constructor or
(methods setNewLines() and some other dealing with
indent... ) but, if I am adding a new line, element...
it writes it for me on the same line then... I do not
need that.

I can of course, after jdom modification write it to
the stream with all the bad stuff trimmed and then
instantly build another DOM to write it with beauty -
but this is dumb. 

Is there a method in JDom, that allows you to get rid
of those 'tabs' and 'newlines' on building a document?
(Something kind of setTrimText() or setNewLines() for
the builder/parser)?

May be I am wrong/didn't notice about something?

Is there some code done to traverse the tree and
remove all the 'tabs' and 'newlines'?

Thank you guys for a wonderful JDOM API by the way. It
took me 10 minutes to jump in and created a great
shortcut in my application development. 

Have a nice day.


=====
Aleksey Nikolayev
admiralspb at yahoo.com

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/



More information about the jdom-interest mailing list