Public void getxml (string URL) throws xmlpullparserexception, ioexception, urisyntaxexception {string xmlstring = downloadxml (URL); xmlpullparserfactory factory = xmlpullparserfactory. newinstance (); factory. setnamespaceaware (true); xmlpullparser parser = factory. newpullparser (); parser. setinput (New stringreader (xmlstring); int eventtype = parser. geteventtype (); List <forecast_conditions> conditionslist = new Arraylist <forecast_conditions> (); forecast_conditions = NULL; while (eventtype! = Xmlpullparser. end_document) {If (eventtype = xmlpullparser. start_document) {system. out. println ("START document");} else if (eventtype = xmlpullparser. start_tag) {system. out. println ("start tag" + parser. getname (); If (parser. getname (). equals ("forecast_conditions") {forecast_conditions = new forecast_conditions ();} If (parser. getname (). equals ("day_of_week") {forecast_conditions.setday_of_week (parser. getattributevalue (0);} else if (parser. getname (). equals ("low") {forecast_conditions.setlow (parser. getattributevalue (0);} else if (parser. getname (). equals ("high") {forecast_conditions.sethigh (parser. getattributevalue (0);} else if (parser. getname (). equals ("icon") {try {forecast_conditions.seticon (parser. getattributevalue (0);} catch (exception e) {// todo: handle exception} else if (parser. getname (). equals ("condition") {try {forecast_conditions.setcondition (parser. getattributevalue (0);} catch (exception e) {}}/* int size = parser. getattributecount (); For (INT I = 0; I <size; I ++) {system. out. println ("attributename" + parser. getattributename (I); system. out. println ("attributevalue" + parser. getattributevalue (I);} */} else if (eventtype = xmlpullparser. end_tag) {system. out. println ("end tag" + parser. getname (); If (parser. getname (). equals ("forecast_conditions") {conditionslist. add (forecast_conditions) ;}} else if (eventtype = xmlpullparser. text) {system. out. println ("text" + parser. gettext ();} eventtype = parser. next ();} system. out. println ("end document"); bindtolistview (conditionslist); // xmlutils .}
This instance is incomplete. Android beginners are not standardized in many places. For reference only.