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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:09:03+00:00 2026-06-13T09:09:03+00:00

How can I show XML tag values on basis of particular condition using local

  • 0

How can I show XML tag values on basis of particular condition using local XML parsing.

E.g. I have this XML file stored in assets folder,

<language>
<languagename>English</languagename>
<contact>EContact</contact>
<update>EUpdate</update>
</language>

<language>
<languagename>Hebrew</languagename>
<contact>HContact</contact>
<update>HUpdate</update>
</language>

I have two buttons, when I click English I want to show data Regarding English and when I click Hebrew , I want to show only Hebrew. Please provide help.

Thanks

  • 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-13T09:09:04+00:00Added an answer on June 13, 2026 at 9:09 am

    This is the XML parser Function it takes the XML as String.

    public class XMLParser {
        public static void parser(String s) {
            try {
                SAXParserFactory spf = SAXParserFactory.newInstance();
                SAXParser sp = spf.newSAXParser();
                XMLReader xr = sp.getXMLReader();
                MyXMLhandler h = new MyXMLhandler();
                xr.setContentHandler(h);
            //  Log.e("string", s);
                xr.parse(new InputSource(new StringReader(s)));
    
            } catch (ParserConfigurationException e) {
                Log.e("ParserError", e.getMessage());
            } catch (SAXException e) {
                Log.e("SAXError", e.getMessage());
            } catch (IOException e) {
                Log.e("IOError", e.getMessage());
            }
    
        }
    }
    

    Use this handler class to extract the information that u need:

    public class MyXMLhandler extends DefaultHandler {
    private boolean language = false;
    private boolean languagename = false;
    private boolean contact = false;
    private boolean update = false;
    
    
    @Override
    public void startElement(String uri, String localName, String qName,
            Attributes attributes) throws SAXException {
        if (localName.equalsIgnoreCase("language")) {
            language = true;
        } else if (localName.equalsIgnoreCase("languagename")) {
            languagename = true;
        } else if (localName.equalsIgnoreCase("contact")) {
            contact = true;
        } else if (localName.equalsIgnoreCase("update")) {
            update = true;
        }
    }
    
    @Override
    public void endElement(String uri, String localName, String qName)
            throws SAXException {
        if (localName.equalsIgnoreCase("language")) {
            language = false;
        } else if (localName.equalsIgnoreCase("languagename")) {
            languagename = false;
        } else if (localName.equalsIgnoreCase("contact")) {
            contact = false;
        } else if (localName.equalsIgnoreCase("update")) {
            update = false;
        }
    }
    
    @Override
    public void characters(char[] ch, int start, int length)
            throws SAXException {
    
        if (language == true) {
            String s = new String(ch, start, length);
    
            Log.w("Language", s);
    
        }
        if (languagename == true) {
            String s = new String(ch, start, length);
    
            Log.w("Languagename", s);
    
        }
        if (contact == true) {
            String s = new String(ch, start, length);
    
            Log.w("contact", s);
    
        }
        if (update == true) {
            String s = new String(ch, start, length);
    
            Log.w("update", s);
    
        }
    
    }
    

    }

    Use this function above and modify it to solve ur problem

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

Sidebar

Related Questions

I have a DataSet consisting of XML data, I can easily output this to
I have exported data .xls file using as3. var xml:ArrayCollection; xml=Labneuron8.lastResult.Response.Terminal as ArrayCollection; var
I would like to know how I can show the output from this piece
Here is my code: (source: http://www.androidhive.info/2011/11/android-xml-parsing-tutorial/ ) Here is my XML file: removed On
how can i show the xml data in UITableView according to the attribute field
I have my parsing xml working but I want to pick up One value
Just a quick check really. I have an XML file that I will be
I Have following in my struts.xml file <action name=ProductVerification class=com.frontend.ProductVerification> <result name=success>/jsp/product_verification.jsp</result> <result name=input>/jsp/product_verification.jsp</result>
I have an XML document similar to: <tag> <content>adsfasdf<b>asdf</b></content> </tag> I would like for
While going through parsing a xml doc i have used multiple if-else to parse

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.