Cool Droid
Lurker
Hi Experts,
I am trying to write an app which calls a web service and read the return xml of the web service.
The webservice is only an aspx file (please see in below code), it returns an xml file.
The code have is working fine when url is a xml file, however, when I change the url to an aspx page, it throws an exception when hitting db.parse(), the exception is:
org.xml.sax.SAXParseException: Unexpected token (position
OCDECL html@3:16 in java.io.InputStreamReader@6c0487b)
I am new to Android/Java coding, I could be using wrong class to parse this type of file. would be much appreciated if someone could help.
Thanks very much in advance!
try {
URL url = new URL("http://www.examplesite.com/sample.aspx?id=111;l=something");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(url.openStream()));
doc.getDocumentElement().normalize();
Node xnd = doc.getElementsByTagName("t").item(0);
String T = xnd.getTextContent();
txtText.setText(T);
}catch (Exception e){
//// TODO: 03-Sep-16
txtText.setText("Error:" + e.getMessage().toString());
}
I am trying to write an app which calls a web service and read the return xml of the web service.
The webservice is only an aspx file (please see in below code), it returns an xml file.
The code have is working fine when url is a xml file, however, when I change the url to an aspx page, it throws an exception when hitting db.parse(), the exception is:
org.xml.sax.SAXParseException: Unexpected token (position
OCDECL html@3:16 in java.io.InputStreamReader@6c0487b) I am new to Android/Java coding, I could be using wrong class to parse this type of file. would be much appreciated if someone could help.
Thanks very much in advance!
try {
URL url = new URL("http://www.examplesite.com/sample.aspx?id=111;l=something");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(url.openStream()));
doc.getDocumentElement().normalize();
Node xnd = doc.getElementsByTagName("t").item(0);
String T = xnd.getTextContent();
txtText.setText(T);
}catch (Exception e){
//// TODO: 03-Sep-16
txtText.setText("Error:" + e.getMessage().toString());
}
