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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:19:10+00:00 2026-05-18T06:19:10+00:00

I want to parse this xml and get the result between the tag… but

  • 0

I want to parse this xml and get the result between the tag… but i cant get the result my xml is

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><loginResponse xmlns="https://comm1.get.com/"><loginResult>true</loginResult><result>success</result></loginResponse></soap:Body></soap:Envelope>

The handler

public class MyXmlContentHandler extends DefaultHandler {
    String result;
    private String currentNode;
    private String currentValue = null;
    public String getFavicon() {
        return result;
    }
    @Override
    public void startElement(String uri, String localName, String qName,
            Attributes attributes) throws SAXException {


        if (localName.equalsIgnoreCase("result")) {
            //offerList = new BFOfferList();
            this.result = new String();

        }
    }

    @Override
    public void endElement(String uri, String localName, String qName)
            throws SAXException {


        if (localName.equalsIgnoreCase("result")) {
            result = localName;

        } 
    }

    @Override
    public void characters(char[] ch, int start, int length)
            throws SAXException {

         String value = new String(ch, start, length);

         if (currentNode.equals("result")){
            result = value;
            return;
         }


}



}

Any changes needed

  • 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-18T06:19:11+00:00Added an answer on May 18, 2026 at 6:19 am

    When you found the start tag you are looking for, “characters” is called one or more times. You have to collect the data not overwrite it. Change

    if (currentNode.equals("result")){
            result = value;
            return;
         }
    

    to

    if (currentNode.equals("result")){
            result += value;
            return;
         }
    

    Or use StringBuilder to do it. Furthermore, you should remove this, it seems to overwrite your result String:

    result = localName;
    

    EDIT:

    public class MyXmlContentHandler extends DefaultHandler {
    
    private String result = "";
    private String currentNode;
    
    public String getFavicon() {
        return result;
    }
    
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
        currentNode = localName;
    }
    
    @Override
    public void endElement(String uri, String localName, String qName) throws SAXException {
        currentNode = null;
    }
    
    @Override
    public void characters(char[] ch, int start, int length) throws SAXException {
    
        String value = new String(ch, start, length);
    
        if ("result".equals(currentNode)){
            result += value;
        }
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to parse an XML document that looks like this: <?xml version=1.0 encoding=UTF-8
I want to parse (little critical) xml using php simplexml...But i can aither get
I have below string in javascript var output = '<?xml version=1.0 encoding=UTF-8 standalone=yes?><abc><xyz><xyzResponse><URL>http%3A%2F%2Flocalhost%3A8080%2Fnet%2Fxyz.do%3Fpartner%3Ddummy%26id%3Dba0e245f-ae67-40b6-986d-3242acea4c04</URL><StatusMsg>SUCCESS</StatusMsg><ID>hello.com</ID><AID>test</AID></xyzResponse></xyz></abc>'; I
I have the following XML: <?xml version=1.0 encoding=UTF-8 standalone=yes?> <application xmlns=http://research.sun.com/wadl/2006/10> <doc xmlns:jersey=http://jersey.dev.java.net/ jersey:generatedBy=Jersey:
I want to parse a html content that have something like this: <div id=sometext>Lorem<br>
Let's say this page www.example.com/mypage returns some html that I want to parse in
I want to be able to parse file paths like this one: /var/www/index.(htm|html|php|shtml) into
I have class model for XML structure, where i want parse xml into it.
I have my parsing xml working but I want to pick up One value
i have a dataset returned by .net webservice and i want to parse this

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.