Handling Empty Tags in XML using Sax Parser, Java
Clash Royale CLAN TAG #URR8PPP Handling Empty Tags in XML using Sax Parser, Java I'm Using Sax parser to handle a pre written xml file....i have no way of changing the xml as it is held by another application but need to parse data from it. The Xml file contains a Tag < ERROR_TEXT/> which is empty when no error is occurred. as a result the parser takes the next character after the tag close which is "n". i have tried result.replaceAll("n", ""); and result.replaceAll("n", ""); how to i get sax to recognise this is an empty tag and return the value as "" ? 4 Answers 4 You don't. It is SAXs job parse the data, not to make decisions on what the content of that data is supposed to be. In your parseHandler, store the string of the data in all your element, and when you go to process that element, do a string.trim() on ...