I am presently using SAXParser with SAXParserFactory, and I have run into a problem with strings being cuttoff at '&' symbols. For example: "Nation Created Our World & everything in it" becomes "everything in it".
Obviously, I dont want this to happen. In the xml input, the character is properly escaped as &
. How can I resolve this?
try{
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader r = sp.getXMLReader();
//This handles the xml and populates the entries array
XMLHandler handler = new XMLHandler();
// register event handlers
r.setContentHandler(handler);
String url = "http://foobar.xml";
r.parse(url);
return handler.getEntries();
}
I have this in my DefaultHandler class
....
public void characters( char ch[], int start, int length ){
String value = new String( ch , start , length );
if(!value.trim().equals("")) {
if( currentElement.equalsIgnoreCase("TITLE") ) {
tempEntry.setTitle(value);
}
....