I'm making an Android application that reads an XML Internet. This application uses SAX to parse XML. This is my code for the part of parsing:
public LectorSAX(String url){
try{
SAXParserFactory spf=SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
DefaultHandler lxmlr=new LibraryXMLReader() ;
sp.parse(url, lxmlr);
nodo=((LibraryXMLReader)lxmlr).getNodoActual();
}catch(ParserConfigurationException e){
System.err.println("Error de parseo en LectorSAX.java: "+e);
}catch(SAXException e){
System.err.println("Error de sax LectorSAX.java: " + e);
} catch (IOException e){
System.err.println("Error de io LectorSAX.java: " + e);
}
}
The problem is that SAXException occurs. The exception message is as follows:
org.apache.harmony.xml.ExpatParser$ParseException: At line 4, column 42: not well-formed (invalid token)
However, if I put the same code in a normal Java SE application, this exception does not occur and everything works fine.
Why the same code works fine in a Java SE application, not an Android?. On the other hand, How to solve the problem?.
Thanks for the help.
Greetings.