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

  • Home
  • SEARCH
  • 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 9189703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:17:41+00:00 2026-06-17T20:17:41+00:00

I have XML file that I downloaded from a web service, the issue that

  • 0

I have XML file that I downloaded from a web service, the issue that I have is that I cannot get it display the data correctly outside of the loop.

The XML format is set up like:

<section>
    <outage>
        <dummydata>test</dummydata>
   </outage>
    <outage>
        <dummydata>test2</dummydata>
   </outage>
</section>
<section>
   <outage>
    <dummydata>test3</dummydata>
   <outage>
</section>

Note some sections can have more that one outage. As you can see below the counts are right but the one outage is from the 4.

01-24 22:54:49.176: I/System.out(1924): Outage Count per sect 1
01-24 22:54:49.176: I/System.out(1924): Outage Count per sect 1
01-24 22:54:49.176: I/System.out(1924): Outage Count per sect 1
01-24 22:54:49.176: I/System.out(1924): Outage Count per sect 1
01-24 22:54:49.176: I/System.out(1924): Outage Count per sect 4
01-24 22:54:49.186: I/System.out(1924): Outage Count per sect 1
01-24 22:54:49.186: I/System.out(1924): Outage Count per sect 1
01-24 22:54:49.196: I/System.out(1924): Outages : 763674

and this is the code that is doing all the work

for (int j = 0; j < arrPolygons.size(); j++) {

     if (isPointInPolygon(point, arrPolygons.get(j).getPoints())) {
      for (int outageInfo = 0; outageInfo < nodeList.getLength(); outageInfo++) {
            outageData = new LinkedList<HashMap<String, String>>();
             Node ouageInfoNode = nodeList.item(outageInfo);

              Element ouageInfoElement = (Element) ouageInfoNode;
              NodeList ouageInfoList = ouageInfoElement.getElementsByTagName("Outage");
              System.out.println("Outage Count per sect "+ouageInfoList.getLength());
                 for (int outages = 0; outages < ouageInfoList.getLength(); outages++) {
                     Node outageNode = ouageInfoList.item(outages);
                     Element outageDataElement = (Element) outageNode;
                     NodeList outageDataList =outageDataElement.getElementsByTagName("outagenum");   

                     outageDataElement = (Element) outageDataList.item(0);
                     outageDataList = outageDataElement.getChildNodes();

                     outagenum = ((Node) outageDataList.item(0))
                            .getNodeValue();

                    //This is what I want to loop 
                      HashMap<String, String> map = new HashMap<String, String>();
                      map.put("outagenum", outagenum);
                    outageData.add(outages, map);                        
                    } 

                }
                  Toast.makeText(MainActivity.this, "Inside " + arrPolygons.get(j).getId()+" "+ outageData.get(j), Toast.LENGTH_LONG).show();

                  System.out.println("Outages : " + outageData.get(0));

              }
           }

         }
    }

my outcome should look like

Index 0 - {test,test2}
Index 1 - {test3}

Can anybody tell me what I am doing wrong within this loop?

  • 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-17T20:17:42+00:00Added an answer on June 17, 2026 at 8:17 pm
     for (int outageInfo = 0; outageInfo < nodeList.getLength(); outageInfo++) {
                outageData = new LinkedList<HashMap<String, String>>();
    

    should

             outageData = new LinkedList<HashMap<String, String>>();
     for (int outageInfo = 0; outageInfo < nodeList.getLength(); outageInfo++) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big xml file that could be downloaded from the internet. To
I have a large XML file (many MBs) that I cannot afford to download
I have an XML file that I'm trying to read from here , and
I have downloaded the Layar401.apk file from web and trying to install it into
I have an XML file that looks like <?xml version=1.0> <playlist> <name>My Playlist</name> <song>
I have an XML file that reads like this <abc> <ab>value</ab> <aa>time</aa> <ac>money</ac> </abc>
I have an XML file that is well formed and valid (matched with an
I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
I have an XML file that has a number of nodes, each of which
I have an XML file that is very long, but here is a shot

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.