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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:07:24+00:00 2026-05-20T14:07:24+00:00

I have developed the following class to retrieve the node-list of a xml document:

  • 0

I have developed the following class to retrieve the node-list of a xml document:

public class XMLDownloader {
    public static NodeList getNodeList(){   
        String url = "http://localhost/xml/example.xml";
        DefaultHttpClient client = new DefaultHttpClient();
        HttpGet method = new HttpGet(url);
        HttpResponse res = null;
        NodeList result = null;

        try {
            res = client.execute(method);
        } catch (ClientProtocolException e1) {
            e1.printStackTrace();
        } catch (IOException e1) {
            e1.printStackTrace();
        }

        try{
            InputStream is = res.getEntity().getContent();
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(is);
            doc.getDocumentElement().normalize();
            result = doc.getElementsByTagName("client");                         
            is.close();

        }catch(Exception e){
             Log.e("log_tag", "Error converting result "+e.toString());
        }       
        return result;              
    }
}

But this method returns null. Any ideas?

The xml file:

<status>
<client type="s" name="test1" protocol="1000">
      </client>
<client type="r" name="test2" protocol="2000"> 
      </client>
<client type="r" name="test3" protocol="3000"> 
      </client>
<client type="h" name="test4" protocol="4000"> 
      </client>
<client type="c" name="test5" protocol="5000"> 
      </client>
</status>
  • 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-20T14:07:25+00:00Added an answer on May 20, 2026 at 2:07 pm

    The code posted in the question actually works for me without any errors. I get a NodeList containing the expected 5 elements. I tried it on an emulator running 2.2.

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

Sidebar

Related Questions

Assume I have the following class-hierarchy in C++: class AbstractBaseClass { public: // Note:
Suppose the following model public class Product { private Integer requiredQuantity; private Integer allowedQuantity;
I have developed on EXE project(use for startup task) and use following dlls of
I have developed the following program/architecture: A) A Java servlet receives POST requests, gets
I have developed demo application using spring struct and hibernate and getting following error
I have developed REST WCF and set binding following way in web.config <bindings> <webHttpBinding>
I have been following a workshop whilst I'm learning C#. One of the class
In a JSF 2 application, which is developed on tomcat, I have the following
I have the following configuration: Visual Studio Team System 2008 SQL Server Developer Edition
I have some data similar to the following chart: http://developer.yahoo.com/yui/examples/charts/charts-seriescustomization_clean.html Only difference is that

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.