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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:49:24+00:00 2026-05-25T01:49:24+00:00

i try to build an application with xml parser. ex : http://www.androidpeople.com/android-xml-parsing-tutorial-using-saxparser but i

  • 0

i try to build an application with xml parser.

ex : http://www.androidpeople.com/android-xml-parsing-tutorial-using-saxparser

but i want to parse xml file from EditText, how it work ?

  • 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-25T01:49:24+00:00Added an answer on May 25, 2026 at 1:49 am

    You have several ways to parse XML, the most widely used being SAX and DOM. The choice is quite strategical as explained in this paper.

    Here is a short explanation of SAX:

    • You will need some imports:

      import org.xml.sax.Attributes;
      import org.xml.sax.SAXException;
      import org.xml.sax.SAXParseException;
      import org.xml.sax.helpers.DefaultHandler;
      import android.util.Xml;
      
    • Create your own XML SAX DefaultHandler:

      class MySaxHandler extends DefaultHandler {
          // Override the methods of DefaultHandler that you need.
          // See [this link][3] to see these methods.
          // These methods are going to be called while the XML is read
          // and will allow you doing what you need with the content.
          // Two examples below:
      
          public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
               // This is called each time an openeing XML tag is read.
               // As the tagname is passed by parameter you know which tag it is.
               // You also have the attributes of the tag.
               // Example <mytag myelem="12"> will lead to a call of
               // this method with the parameters:
               // - localName = "mytag"
               // - attributes = { "myelem", "12" }  
          }
      
          public void characters(char[] ch, int start, int length) throws SAXException {
               // This is called each time some text is read.
               // As an example, if you have <myTag>blabla</myTag>
               // this will be called with the parameter "blabla"
               // Warning 1: this is also called when linebreaks are read and the linebreaks are passed
               // Warning 2: you have to memorize the last open tag to determine what tag this text belongs to (I usually use a stack).
          }
      }
      
    • Extract the XML as a String from the EditText. Let’s call it xmlContent

    • Create and initialize your XML parser:

      final InputStreamReader reader = new InputStreamReader(new ByteArrayInputStream(xmlContent.getBytes()));
      final MySaxHandler handler = new MySaxHandler();
      
    • And then, make the XML content to be read by the parser. This will lead your MySaxHandler to have its various method called while the reading is in progress.

      Xml.parse(reader, handler);
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following the MapView tutorial on the Android website [2010-08-22 11:12:24 - com.android.ide.eclipse.adt.internal.project.AndroidManifestParser] Parser
I try to build some application using hibernate for persistence (my first one). The
I try to build a gui (Swing) for a simple java application. The application
i am using jwsc to build my webservices application. This produces a war file
When I try to build my project I get the following message in the
When I try to build my projects in Visual Studio 2008, web sites won't
I'm getting an error message when I try to build my project in eclipse:
I am about to try and automate a daily build, which will involve database
Every time I have to build a form with a DateTime field I try
I try to fetch a Wikipedia article with Python's urllib: f = urllib.urlopen(http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes) s

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.