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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:17:33+00:00 2026-06-03T06:17:33+00:00

I am doing an Android application. In my app I have to parse a

  • 0

I am doing an Android application. In my app I have to parse a xml page.The data in the xml page is in the following format.

<root>
<tag1>data</tag1>

<tag2> 
<div>data1</div><div>data2</div>
</tag2>
</root>

to tried to take data through sax parsing.

 if (localName.equalsIgnoreCase("tag1"))
if (localName.equalsIgnoreCase("tag2"))

But I am not getting any data from tag2 but getting value from tag1.I want to get all data include div tag also then only i can show data in like html page.

  • 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-06-03T06:17:34+00:00Added an answer on June 3, 2026 at 6:17 am

    Use this sample code

    public class SAXParserDemo extends DefaultHandler {
    
        private String currentTag = "";
        private StringBuffer responseTag;
        private String str;
    
        @Override
        public void startDocument() throws SAXException {
            super.startDocument();
    
        }
    
        @Override
        public void endDocument() throws SAXException {
            super.endDocument();
        }
    
        @Override
        public void startElement(String uri, String localName, String name,
                Attributes attributes) throws SAXException {
            super.startElement(uri, localName, name, attributes);
    
            currentTag = localName;
            if ("tag1".equalsIgnoreCase(localName)) {
                responseTag = new StringBuffer();
            }else if ("tag2".equalsIgnoreCase(localName)) {
                responseTag = new StringBuffer();
            }else if ("div".equalsIgnoreCase(localName)) {
                responseTag = new StringBuffer();
            }
        }
    
        @Override
        public void endElement(String uri, String localName, String name)
                throws SAXException {
            super.endElement(uri, localName, name);
            String responseValue = responseTag.toString().trim();
    
            if ("tag1".equalsIgnoreCase(localName)) {
                Log.v("TAG", "Tag 1 value "+responseValue);
            }else if ("tag2".equalsIgnoreCase(localName)) {
                Log.v("TAG", "Tag 2 value "+responseValue);
            }else if ("div".equalsIgnoreCase(localName)) {
                Log.v("TAG", "div value "+responseValue);
            }
        }
    
        @Override
        public void characters(char[] ch, int start, int length)
                throws SAXException {
            super.characters(ch, start, length);
            str = new String(ch, start, length);
    
            if ("tag1".equalsIgnoreCase(currentTag)) {
                responseTag.append(str);
            }else if ("tag2".equalsIgnoreCase(currentTag)) {
                responseTag.append(str);
            }else if ("div".equalsIgnoreCase(currentTag)) {
                responseTag.append(str);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem: I am working on an Android application where at
I am doing an contact list android application but i have a small problem
I am doing an contact list android application but i have a small problem
Does upgrading Android application delete files from private data directory? I have tested this
Now i am doing an android application.In that application I am using asynchtask class
I'm doing a schedule sms application in android using eclipse. The designing part is
I am doing a streamed musicplayer for android. I have tried with MediaPlayer mp.setDataSource(http://www.myServerPage.com/songUrl.mp3);
I am doing NDK profiling for my project using android-ndk-profiler-3.1. I have made changes
When parsing an xml file in android, I'm doing like this: try { InputStream
I have android application that is written regular way. layouts, java, APK. Now, depending

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.