I would like to know if there is a way to remove all "ignorable whitespace"
from an XML document when you parse it to create a document object?

I thought I was close by using
DocumentBuilderFactory.setIgnoringElementContentWhiteSpace(true) however,
this requires you to also set DocumentBuilderFactory.setValidating(true).
When validating is turned on it expects to validate against a DTD, I'm not
using DTD's I just want to eliminate CR's and other unnecessary whitespace.

For example,
turn this original xml file:
<root>
      <elem1>somevalue</elem1>
      <elem2>some other value</elem2>
</root>

to this document object:
<root><elem1>somevalue</elem1><elem2>some other value</elem2></root>

TIA

Reply via email to