I have a SAXParser with with an XMLReader.
SAXParserFactory saxPF = SAXParserFactory.newInstance();
SAXParser sp = saxPF .newSAXParser();
XMLReader xmlR = sp.getXMLReader();
MyHandler myHandler = new MyHandler();
xmlR .setContentHandler(myHandler );
My handler code uses startElement and endElement to detect with it's inside a tag. It does this by setting a boolean and using characters() to grab the value
public void startElement(String namespaceURI,
String localName, String qName, Attributes atts) throws SAXException {
if (localName.equals("myTag")) this.in_myTag = true;
}
public void characters(char ch[], int start, int length) {
if(in_myTag ) { c.setMyTag(new String(ch, start, length));
}
The problem is that I have a tag that is "A & B Value" and it's notifying characters() for "A" and "&" and "B" and "Value". So the final value of setMyTag is "Value"
<myTag>A & B value</myTag>
http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html