What's wrong with the following Parse code?

Monday, May 12, 2014

I am new to Parser and following are my code for retrieving the state of a sensor is as following. There is no response for the button clicking. How would I fix this?


OnClick method:



public void loginconfirmm(View v){
//String BayState="Free";
final String baseURL="http://ift.tt/1nFWvd9";
//c is the retrieving result from reservation table
//String c="1";
//String b="Bay"+c;
//StringBuilder URL=new StringBuilder(baseURL);
//URL.append(b);
String fullUrl=baseURL.toString();

try{
URL website=new URL(fullUrl);
//gettin gxmlreader to parse data
SAXParserFactory spf=SAXParserFactory.newInstance();
SAXParser sp=spf.newSAXParser();
XMLReader xr=sp.getXMLReader();

HandlingXMLStuff doingWork=new HandlingXMLStuff();
xr.setContentHandler(doingWork);
xr.parse(new InputSource(website.openStream()));

String information=doingWork.getInformation();
Message.message(this, information);

}catch(Exception e){

}
}


XML handler:



public class HandlingXMLStuff extends DefaultHandler{
private XMLDataCollected info=new XMLDataCollected();

@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
// TODO Auto-generated method stub
if (localName.equals("baystate")){
String state=attributes.getValue("state");
info.setId(state);
}

}

public String getInformation(){
return info.dataToString();
}
}


XML data collected:



public class XMLDataCollected {
String Baystate=null;

public void setId(String state){
Baystate=state;
}

public String dataToString(){
return Baystate;
}
}






http://ift.tt/1gfrkpq