|
|
||||
|
||||
|
|
||||
|
||||
|
|
|
|
||||
|
||||
|
|
||||
|
||||
|
|
XML FAQ | |
|
This is the FAQ page for the XML and Related Technologies forum. Contributions are welcome. Also see XmlLinks.
Q: The characters() method in my SAX parser doesn't return all the text (or is called more than once). What gives? Here's what the javadocs of that method say: SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks. William Brogden explains : The characters() method may be called any number of times within a single element because the SAX parser only handles one bufferload of input characters at a time. It is up to the programmer to assemble the text properly. I normally have a StringBuffer or StringBuilder reference that gets a new instance when the appropriate startElement() is hit and gets additions from each call to the characters() method. When endElement() occurs I use toString() to get the assembled characters and then work on the logic.
JavaDoc:org.xml.sax.ContentHandler
Java Code Examples Many frequently asked questions have been answered nicely in the Java Developer's Almanac (JavaAlmanac:dom and JavaAlmanac:xml) so you might want to check those first.
Articles and introductions General
Specifically about Java
Software
CategoryFaq XmlLinks | |