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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:16:03+00:00 2026-05-21T11:16:03+00:00

I have read many articles about XML parsing in Android. However, all of them

  • 0

I have read many articles about XML parsing in Android. However, all of them are just code without any explaination. I’m new to Android (and even Java), however, I have been with .NET for a long time. So please explain me some classes:

SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();

What do they do?

xr.parse(new InputSource(sourceUrl.openStream()));

This parse a XML file from the Internet. How can I parse a XML file in res/raw? And even with a XML file in SD Card?

Is there any class like XMLDocument in .NET? And how can I write XML file into SD Card?

Thank you.

  • 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-21T11:16:04+00:00Added an answer on May 21, 2026 at 11:16 am

    The first three lines just set up an XML parser. The variant of parser is a stream parser, that does not need the full input as a tree in memory (that would be a dom parser), but which reads the xml data as it streams by.

    Do read stuff from the assets folder you could use that code:

      AssetManager assetManager = context.getAssets();
            try {
                InputStream is = assetManager.open("1.xml");
                board = new Board();
                board.loadFromXmlInputStream(is);
                is.close();
    

    where board.loadFromXmlInputStream(is); internally calls your above 3 lines of code and then xr.parse(new InputSource(is)

    See e.g. SampleView for the above lines and the Board.

    Note that your code above will not be enough to process the XML – you also need some callbacks (like the ones shown in the Board class).

    As an alternative you can also use a DOM parser, that creates a tree representation of the XML in memory that you can then walk.

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

Sidebar

Related Questions

I have just read many, many articles on SO about hashing passwords with salt
I have read many question about improving the performance of C++ and C code
I have read many questions about Android, J2ME and RecordStore , but I still
I have read so many articles about integration and yet i did not found
I have read many about REST api in php articles. but I still get
I have read almost all articles about Repository pattern and different implementations of it.
I have read many articles about vertical centering but I’m afraid not many of
I have read many articles about linq to sql performance. The result which i
I am beginning to write a Facebook application. I have read many articles about
I've read many articles and blogs about mocking in mvc... Many of them were

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.