Hi ,
I have two queries based on XML parsing which comes as httpresponse.
I am sending an httprequest to a site with a GET header. The response I
expect is to be in XML.
First, I need to know whether I am getting XML as the httpresponse. Is there
any method which checks whether the received response is in XML or not?
Second, I need help in parsing the XML which I get from the httpresponse.
I am pasting a code snippet here which I have written :
URL url = new URL(uri); //url
URLConnection conn = url.openConnection();
HttpURLConnection httpcon = (HttpURLConnection)conn;
httpcon.setRequestMethod("GET");
httpcon.setDoInput(true);
httpcon.setDoOutput(true);
httpcon.setRequestProperty("xxxx", "xxxxxxxx"); //request
header
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
MySAXHandler xmlhandler = new MySAXHandler(); //xml parsing file
xr.setContentHandler(xmlhandler);
//from here, i need to parse the xml from httpresponse, but dunno
whether this code is right
InputStream is = conn.getInputStream();
xr.parse(new InputSource(is));
ArrayList<StoreClass> arr = xmlhandler.getParsedData();
//for storing the elements in XML
Can you guys look at the above code and tell me how to get the xml data from
the httpresponse?
Thanks,
Ashok Jeevan
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en