parsing xml from a network database in android -


When I click on a button, I want to show an XML file that is stored in a URL database. , How to do this, please give me an example.

Get data on a server side script, and return it as XML, then download the page and Load it into your application.

Using this code, you can get an XML file from an online database and it can be parsed as an XML document in Android.

  Documentation xmldocument = fromString (Download Page ("http://example.com/data.php");   

This is a short script The webpage should download and return it as a string

  public string download page (string target ur) {try buffer = null; try // // desired page url url = new url (Target URL); = new BufferedReader (new InputStreamReader (url.openstream ()) by the server; String; output string = ""; while ((str = in.readLine ()) = null {// str is a line of text; readLine () new line / letters / output + = "\ n"; output + = Str;} Return output. Substring (1);} Catch (MalmarmdureLecepation E) {} Catch (IOexception E) {} Finally {try (if! = Zero) in.close ();} Grip (IOException E) {}} Return Null;}   
  Public static document {if (xml == faucet) from String (string xml) is a simple dome parser for throwing new NullPointerException ("X" in Mel is null string "); See http://www.rgagnon.com/javadetails/java-0573.html {DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance (); DocumentBuilder db = dbf.newDocumentBuilder (); Input source = new input source (); Is.setCharacterStream (new stringreader (xml)); Document Doctor = DB Pars (is); Return doctor} hold (SAXException e) {return tap; } Hold (Exception e) {CustomExceptionHandler Yes = New CustomExceptionHandler (); Han.uncaughtException (Thread.currentThread (), e); Return tap; }}    

Comments