Preserving whitespace in DOM
Hi All,
Suppose I have an xml fragment within a valid xml file which is like
"<input name='test'>". When doing DocumentBuilder.parse(xmlString), is it possible to preserve the space after 'test' and before '>'? Right now when I print the document the whitespace is stripped. I'm using apache's XMLSerializer.
Thank you.
[363 byte] By [
ysh78NJa] at [2007-11-27 9:10:48]

# 1
http://xerces.apache.org/xerces-j/apiDocs/org/apache/xml/serialize/XMLSerializer.html
=> setOutputFormat(org.apache.xml.serialize.OutputFormat)
http://xerces.apache.org/xerces-j/apiDocs/org/apache/xml/serialize/OutputFormat.html
=>setPreserveSpace(boolean) (true in your case)
# 2
Thanks for your quick response. I've tried both settings in the XMLSerializer, but I suspect that when the document object itself is created, the whitespace info is being lost. I tried the whitespace setting on the DocumentBuilderFactory object but that didn't make a difference.