I am trying to create an XML document using the JDK 1.5 DocumentBuilderFactory class. I am using the following statement to read the sample XML string below and create an XML document. The problem I'm having is with the way the input document is parsed. The FIELD2 element in the output document is an empty element. I need the spaces from the input document to remain in the output. I checked the documentBuilderFactory.isIgnoringElementContentWhitespace() and it is set to FALSE (default). How can I parse this document and retain elements with blank text values?
Since all the other white space in your document is being preserved, my guess is that there actually is no space between the FIELD2 start tag and end tag.
Joined: Aug 29, 2008
No a space actually does exist. This is just an example but there are other documents with more than just one space and they all result in empty elements. To confirm this I have printed the string containing the XML before parsing and the spaces are there.