You are currently viewing the XML section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
I have written a SAX program to parse an XML document. But the XML document does contains newline characters. I want to replace every newline character with a space. Is there any callback method for this and how do I do this?
<address>St John Road
Postcode 56</address>
My output: is St John Road
Postcode 56
The text node is notified to the characters() event in your ContentHandler, which can modify the content any way it likes.
The parser is allowed to make multiple calls on characters(), dividing the text into fragments any way it likes, so you should buffer it up and process it the next time endElement or startElement is called.
Michael Kay http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference