Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3662900
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:28:09+00:00 2026-05-19T01:28:09+00:00

Can anyone tell me how to parse a local XML file stored in the

  • 0

Can anyone tell me how to parse a local XML file stored in the system using SAX, with an example code? Please also tell me where can I find information on that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:28:10+00:00Added an answer on May 19, 2026 at 1:28 am

    To read from XML in your app, create a folder in your res folder inside your project called “xml” (lower case). Store your xml in this newly created folder. To load the XML from your resources,

    XmlResourceParser myxml = mContext.getResources().getXml(R.xml.MyXml);//MyXml.xml is name of our xml in newly created xml folder, mContext is the current context
    // Alternatively use: XmlResourceParser myxml = getContext().getResources().getXml(R.xml.MyXml);
    
    myxml.next();//Get next parse event
    int eventType = myxml.getEventType(); //Get current xml event i.e., START_DOCUMENT etc.
    

    You can then start to process nodes, attributes etc and text contained within by casing the event type, once processed call myxml.next() to get the next event, i.e.,

     String NodeValue;
        while (eventType != XmlPullParser.END_DOCUMENT)  //Keep going until end of xml document
        {  
            if(eventType == XmlPullParser.START_DOCUMENT)   
            {     
                //Start of XML, can check this with myxml.getName() in Log, see if your xml has read successfully
            }    
            else if(eventType == XmlPullParser.START_TAG)   
            {     
                NodeValue = myxml.getName();//Start of a Node
                if (NodeValue.equalsIgnoreCase("FirstNodeNameType"))
                {
                        // use myxml.getAttributeValue(x); where x is the number
                        // of the attribute whose data you want to use for this node
    
                }
    
                if (NodeValue.equalsIgnoreCase("SecondNodeNameType"))
                {
                        // use myxml.getAttributeValue(x); where x is the number
                        // of the attribute whose data you want to use for this node
    
                } 
               //etc for each node name
           }   
            else if(eventType == XmlPullParser.END_TAG)   
            {     
                //End of document
            }    
            else if(eventType == XmlPullParser.TEXT)   
            {    
                //Any XML text
            }
    
            eventType = myxml.next(); //Get next event from xml parser
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me why this code would not be working? $('body').on('test', function() {
can anyone tell me how to select data by date in MS.ACCESS database using
Can anyone tell me why the following code fails to submit the form into
Can anyone tell me, how to make shadow, using UIPageViewController, around of my background
Can anyone tell me how to substring a GridView BoundField object please? I tried
Can anyone tell me what is wrong with this code block? The PHP compiler
Can anyone tell me why callbacks are not working for the like-button code given
Can anyone tell me why this code generates queue after starting the threads? Basically,
Can anyone tell me how to parse SOAP output into list form? Here is
Can anyone tell me why this doesn't work? It's just a crude example of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.