Extra blanks and lines in SAX Parsers "procedure charac

Posted by scott_auge on 14-Sep-2017 15:09

I have a well formed XML document, so that isn't the problem.

There isn't any mystery characters in the document (out of code base) so that isn't the problem.

Why, for elements, would I be getting x spaces and x lines of those spaces at the end of the data?

Posted by Peter Judge on 14-Sep-2017 15:34

It’s legal XML.
 
I clean up the characters in the EndElement handler (TRIM etc). The Characters handler just appends to a longchar. The lognchar is cleared in the StartElement handler.
 

All Replies

Posted by Peter Judge on 14-Sep-2017 15:18

What does the data look like?
 
IIRC the SAX parser will return everything between the element’s start > and the </

Posted by Thomas Mercer-Hursh on 14-Sep-2017 15:27

Sounds like the XML has been formatted for easy reading by a human, introducing extra spaces and line breaks.

Posted by scott_auge on 14-Sep-2017 15:31

Ah, yea - that's the problem.

I am reading an indented XML file.

It appears to find an element, and start reading in blanks until the start of the next element.

Any ideas how to prevent this?

Posted by Peter Judge on 14-Sep-2017 15:34

It’s legal XML.
 
I clean up the characters in the EndElement handler (TRIM etc). The Characters handler just appends to a longchar. The lognchar is cleared in the StartElement handler.

Posted by scott_auge on 15-Sep-2017 09:15

Using the trim() so simplified the code and understanding where the extra data was coming from were the indentions in the file.  We are good to go!

This thread is closed