xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rahul Srivastava" <rsrivast...@firstam.com>
Subject RE: DocumentBuilder.parse(File file)
Date Mon, 21 Apr 2003 05:15:31 GMT
Hi Matt,

When you load a XML from a file as a DOM, the whitespaces become a part of
the DOM as nodes. I suspect, you are using a 'println' in some places, to
write out the nodes to the stream, and hence, when printing such a
whitespace node using println, you get, extra blank lines, or CRs.

You can avoid the creation of these whitespace nodes by using
setIgnoringElementContentWhitespace() on DBF, but, note that, this works,
when you have an associated grammar, and that grammar MUST be a DTD,
otherwise, this feature won't work. In that case, you have to modify your

Anyways, you can post your code, if still, this does not fix your problem.
BTW, You might be interested in having a look at the XMLSerializer of


-----Original Message-----
From: Matthew Oatham [mailto:matthewoatham@hotmail.com]
Sent: Monday, April 14, 2003 8:25 PM
To: general@xml.apache.org
Subject: DocumentBuilder.parse(File file)


I am loading an XML file in to DOM using DocumentBuilder.parse(File file).

I have written an XML writer which takes a DOM and writes it to file I have
tested this and know it works as expected when creating a new DOM in memory.

However when I create a DOM from an existing xml file then write it to disk
using my xml writer there are blank line or carriage returns in the new file
which didn't exist in the original. I suspect these are being inserted when
the DOM is created from an existing file but can't prevent or solve it. Does
anyone have an explanation or ideas to prevent or solve.



In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org

View raw message