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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:55:48+00:00 2026-06-04T01:55:48+00:00

For this given code I am getting an exception. I don’t know how to

  • 0

For this given code I am getting an exception. I don’t know how to clear this.

package com.new_xml_parse;
import java.net.URL;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
public class New_xml_parseActivity extends Activity 
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
/** Create a new layout to display the view */
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(1);
/** Create a new textview array to display the results */
TextView name[];
TextView website[];
TextView category[];
try
{
URL url = new URL("http://bestpropertyworld.com/MobileApp/xml1.xml");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(new InputSource(url.openStream()));
doc.getDocumentElement().normalize();
NodeList nodeList = doc.getElementsByTagName("item");
/** Assign textview array lenght by arraylist size */
name = new TextView[nodeList.getLength()];
website = new TextView[nodeList.getLength()];
category = new TextView[nodeList.getLength()];
for (int i = 0; i < nodeList.getLength(); i++)
{
Node node = nodeList.item(i);
name[i] = new TextView(this);
website[i] = new TextView(this);
category[i] = new TextView(this);
Element fstElmnt = (Element) node;
NodeList nameList = fstElmnt.getElementsByTagName("name");
Element nameElement = (Element) nameList.item(0);
nameList = nameElement.getChildNodes();
name[i].setText("Name = "+ ((Node) nameList.item(0)).getNodeValue());
NodeList websiteList = fstElmnt.getElementsByTagName("website");
Element websiteElement = (Element) websiteList.item(0);
websiteList = websiteElement.getChildNodes();
website[i].setText("Website = "+ ((Node) websiteList.item(0)).getNodeValue());
category[i].setText("Website Category = "+ websiteElement.getAttribute("category"));
layout.addView(name[i]);
layout.addView(website[i]);
layout.addView(category[i]);
}
} 
catch (Exception e)
{
System.out.println("XML Pasing Excpetion = " + e);
}
/** Set the layout view to display */
setContentView(layout);
}
}

in LogCat i am getting like this, Give give solution for this

05-18 15:16:00.132: W/WindowManager(77): Failure taking screenshot for (180x300) to layer 21010
05-18 15:16:00.151: W/NetworkManagementSocketTagger(77): setKernelCountSet(10013, 1) failed with errno -2
05-18 15:16:00.681: I/Process(77): Sending signal. PID: 187 SIG: 3
05-18 15:16:00.698: I/dalvikvm(187): threadid=3: reacting to signal 3
05-18 15:16:01.151: I/dalvikvm(187): Wrote stack traces to '/data/anr/traces.txt'
05-18 15:16:02.121: W/NetworkManagementSocketTagger(77): setKernelCountSet(10041, 0) failed with errno -2
05-18 15:16:02.902: D/dalvikvm(187): GREF has increased to 201
05-18 15:16:03.573: D/dalvikvm(187): GC_FOR_ALLOC freed 594K, 6% free 11501K/12167K, paused 114ms
05-18 15:16:03.601: I/dalvikvm-heap(187): Grow heap (frag case) to 12.399MB for 1157776-byte allocation
05-18 15:16:03.851: D/dalvikvm(187): GC_CONCURRENT freed 23K, 6% free 12608K/13319K, paused 25ms+7ms
05-18 15:16:04.087: D/dalvikvm(187): GC_FOR_ALLOC freed 1K, 6% free 12608K/13319K, paused 67ms
05-18 15:16:04.101: I/dalvikvm-heap(187): Grow heap (frag case) to 13.524MB for 1203064-byte allocation
05-18 15:16:04.251: D/dalvikvm(187): GC_CONCURRENT freed 0K, 6% free 13783K/14535K, paused 18ms+7ms
05-18 15:16:04.491: D/dalvikvm(187): GC_FOR_ALLOC freed 4K, 6% free 13780K/14535K, paused 49ms
05-18 15:16:04.501: I/dalvikvm-heap(187): Grow heap (frag case) to 14.625MB for 1157776-byte allocation
05-18 15:16:04.561: D/dalvikvm(187): GC_FOR_ALLOC freed 0K, 5% free 14911K/15687K, paused 58ms
05-18 15:16:05.971: D/dalvikvm(187): GC_FOR_ALLOC freed 56K, 4% free 16198K/16839K, paused 57ms
05-18 15:16:06.411: D/dalvikvm(187): GC_FOR_ALLOC freed 16K, 4% free 17678K/18311K, paused 79ms
05-18 15:16:07.231: D/dalvikvm(187): GC_CONCURRENT freed 614K, 4% free 19055K/19847K, paused 6ms+8ms
05-18 15:16:07.391: I/ActivityManager(77): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.new_xml_parse/.New_xml_parseActivity} from pid 187
05-18 15:16:07.391: W/WindowManager(77): Failure taking screenshot for (180x300) to layer 21005
05-18 15:16:07.474: W/NetworkManagementSocketTagger(77): setKernelCountSet(10041, 1) failed with errno -2
05-18 15:16:07.637: I/System.out(572): XML Pasing Excpetion = android.os.NetworkOnMainThreadException
05-18 15:16:08.023: I/Process(77): Sending signal. PID: 572 SIG: 3
05-18 15:16:08.031: I/dalvikvm(572): threadid=3: reacting to signal 3
05-18 15:16:08.372: I/dalvikvm(572): Wrote stack traces to '/data/anr/traces.txt'
05-18 15:16:08.591: I/Process(77): Sending signal. PID: 572 SIG: 3
05-18 15:16:08.591: I/dalvikvm(572): threadid=3: reacting to signal 3
05-18 15:16:08.611: I/dalvikvm(572): Wrote stack traces to '/data/anr/traces.txt'
05-18 15:16:08.735: I/ActivityManager(77): Displayed com.new_xml_parse/.New_xml_parseActivity: +1s260ms
05-18 15:16:09.191: W/NetworkManagementSocketTagger(77): setKernelCountSet(10013, 0) failed with errno -2
05-18 15:16:09.224: W/InputManagerService(77): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@41558698 (uid=10013 pid=187)
05-18 15:16:09.621: D/dalvikvm(187): GC_FOR_ALLOC freed 2277K, 12% free 18638K/21127K, paused 79ms
05-18 15:16:34.761: D/dalvikvm(172): GC_CONCURRENT freed 387K, 6% free 9534K/10119K, paused 7ms+4ms
  • 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-04T01:55:50+00:00Added an answer on June 4, 2026 at 1:55 am

    your main thread cant handle XML parsing.so use AsyncTask.to complete your xml parsing.

    See this Example

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

Sidebar

Related Questions

Given this sample code: #include <iostream> #include <stdexcept> class my_exception_t : std::exception { public:
Given this stack trace snippet Caused by: java.net.SocketException: Software caused connection abort: socket write
I am brand new to Java and was given this piece of code, no
Given this Java code: class Account { private Integer number = 0; public synchronized
Given this code: var arrayStrings = new string[1000]; Parallel.ForEach<string>(arrayStrings, someString => { DoSomething(someString); });
Given this code: List<string> things = new List<string>(); foreach (string thing in things) {
So I was given this code in a folder of bits and pieces that
I was given this Python code that would calculate an MD5 value for any
I pasted the code given in this link to a file called md5.js. http://www.webtoolkit.info/javascript-md5.html
Given this piece of code : public static void writeFile(File file,List buffer)throws IOException{ File

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.