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 5847149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:40:40+00:00 2026-05-22T12:40:40+00:00

I am new to programming, so to start with correct me if I am

  • 0

I am new to programming, so to start with correct me if I am wrong in the paragragh below :

There is mainly three xml parsers for use in Android : Sax, Dom, and XmlPullParser. That last option, while existing as an external ressource. Is “in the core” of Android, thus working faster, but the functionnalities are limited

Ok here is my Question I slightly modified the code provided in the link below

http://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html

I did the following :

import java.io.IOException;
import java.io.StringReader; 
import org.xmlpull.v1.XmlPullParser; 
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory; 

public class xmlPParser
{   

    public String texte;
    public xmlPParser (String arg)         
      throws XmlPullParserException, IOException     
    {
         XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
         factory.setNamespaceAware(true);
         XmlPullParser xpp = factory.newPullParser();
         xpp.setInput( new StringReader ( arg ) );
         int eventType = xpp.getEventType();



         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 "+xpp.getName()); } 
        //else if(eventType == XmlPullParser.END_TAG) {  System.out.println("End tag "+xpp.getName()); }
        if(eventType == XmlPullParser.TEXT){ texte = xpp.getText();  }    //{ System.out.println("Text "+xpp.getText());}          

        eventType = xpp.next();
            }         

         //System.out.println("End document");
         } 

        public String getTexte()
        {
            String returnTexte = texte;
            return returnTexte;
        }

} 

In another java file, I can call the parser in the following way :

public xmlPParser myxpp;

…

myxpp = new xmlPParser("<foo>Hi five !!</foo>");

On that last line : I would like to be able to ask the parser to go to a file, instead of passing a string to it. how would i do that ?
I am not sure how to make use of this posting
Does getResources().getXml() supposes I am using the Android pullParser which I am not sure to be using now ?

  • 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-22T12:40:40+00:00Added an answer on May 22, 2026 at 12:40 pm

    XmlPullParser is not really a parser, it is an interface to a type of parser, called a “pull” parser.

    The function getResources().getXml() returns an implementation of XmlPullParser for “parsing” XML resources. This is not a real XML parser — in fact the original XML file was parsed at build time before being built into your app, and what this “XML parser” is doing is just returning the pre-digested XML structure as you call its API. This is the fastest “XML” parser available on Android (because it is not really parsing anything), but requires that the XML document be compiled as part of building your app.

    The other implementation of XmlPullParser that you get from XmlPullParserFactory.newInstance() is not “limited” — this implementation is full-featured, and can parse any raw XML document you give to it.

    At least at one time (not sure if this is still the case), both the SAX parser and the parser returned by XmlPullParserFactory.newInstance() are actually built on the same underlying implementation, which is expat. The expat parser is a “push” parser (that is the same model as SAX), so the most efficient way to use it is with the SAX API. The XmlPullParser version has some more overhead from SAX since it needs to turn the underlying push semantics into a pull interface.

    If it helps — push means that it pushes the parsed data to you (callbacks you implement giving you each tag and other document element), while pull means you make calls to the parser to retrieve each element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to programming, and am wondering if there is a correct way
I'm quite new to programming, and I was wondering if there is a good
So I want to start and say I am new to Java programming. Here
Let me start by saying, I am new to Java programming. I have coded
I am new to iPhone programming and would like to be able to use
I'm looking to start a new programming language and for my first task I
I am new to programming (previously only did html/css/design) trying to start learning RoR
i been thinking of a new programming language. Before trying to implement it i
Im new to programming and I dont know very much about but I'm making
I'm fairly new at programming, but I've wondered how shell text editors such as

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.