I'm parsing the following XML using parser:
<Person>
<Name>Test</Name>
<Phone>111-111-2222</OtherPhone>
<Address>lee h&y</Address>
<Person>
The characters method of the sax parser is only reading the address data until 'lee h' as it does not consider '&' as a character. I need to get the complete text in the address element. Any ideas on how I should do it? This is my sax parser(here address is a flag which notifies that an address element is present in XML):
boolean address=false;
public void startElement(String uri, String localName,
String qName, Attributes attributes)
throws SAXException {
if (qName.equalsIgnoreCase("Address")) {
address= true;
}
public void characters(char ch[], int start, int length)
throws SAXException {
String data = new String(ch, start, length);
if (address) {
System.out.println("Address is: "+data);
address = false;
}
and the output is:: lee h