Code example for android to read xml

Source: Internet
Author: User
Code snippets, code sharing, PHP code sharing, Java code sharing, Ruby code sharing, Python code sharing, HTML code sharing, CSS code sharing, SQL code sharing, and JavaScript code sharing
/*** Get version information and application id from config. xml *** @ param urlPath * @ return * @ throws Exception */public List
 
  
GetUpdateInfo () {Resources r = context. getResources (); // use Resources to obtain the XmlResourceParser instance XmlResourceParser xrp = r. getXml (R. xml. config); List
  
   
List = new ArrayList
   
    
(); // If it is the start tag try {// if it is not at the end of the file, continue executing while (xrp. getEventType ()! = XmlResourceParser. END_DOCUMENT) {// if it is the start tag if (xrp. getEventType () = XmlResourceParser. START_TAG) {// Obtain the tag name String name = xrp. getName (); // Determine whether the tag name is friendif (name. equals ("update") {// Obtain the tag attribute and append it to the list in StringBuilder. add (xrp. getAttributeValue (0); list. add (xrp. getAttributeValue (1); list. add (xrp. getAttributeValue (2);} else if (xrp. getEventType () = XmlPullParser. END_TAG) {} else if (xrp. getEventType () = XmlPullParser. TEXT) {}// the next tag xrp. next () ;}} catch (XmlPullParserException e) {e. printStackTrace ();} catch (IOException e) {e. printStackTrace ();} return list ;}
   
  
 

The above is the detailed content of the code instance for android to read xml. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.