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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:19:31+00:00 2026-06-17T06:19:31+00:00

Hello i am parsing xml by below code @Override protected void onCreate(Bundle savedInstanceState) {

  • 0

Hello i am parsing xml by below code

       @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    InputStream is = getResources().openRawResource(R.raw.bd);
    try {
        DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document doc = docBuilder.parse(is, null);
        doc.getDocumentElement().normalize();
        NodeList my_words = doc.getElementsByTagName("word");
        for (int i = 0; i < 100; i++) {
            System.out.println(((Element) my_words.item(i)).getAttribute("eng"));
            System.out.println(((Element) my_words.item(i)).getAttribute("guj"));
        }
        is.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

but i am getting error like below…

          01-11 16:00:48.709: E/dalvikvm-heap(18535): Out of memory on a 176-byte allocation.
          01-11 16:00:48.709: I/dalvikvm(18535): "main" prio=5 tid=1 RUNNABLE
          01-11 16:00:48.709: I/dalvikvm(18535):   | group="main" sCount=0 dsCount=0 obj=0x40022190 self=0xd018
          01-11 16:00:48.709: I/dalvikvm(18535):   | sysTid=18535 nice=0 sched=0/0 cgrp=[fopen-error:2] handle=-1345002400
          01-11 16:00:48.709: I/dalvikvm(18535):   at java.lang.Throwable.nativeFillInStackTrace(Native Method)
          01-11 16:00:48.709: I/dalvikvm(18535):   at java.lang.Throwable.fillInStackTrace(Throwable.java:135)
          01-11 16:00:48.709: I/dalvikvm(18535):   at java.lang.Throwable.<init>(Throwable.java:74)
          01-11 16:00:48.709: I/dalvikvm(18535):   at java.lang.Error.<init>(Error.java:38)
          01-11 16:00:48.709: I/dalvikvm(18535):   at java.lang.VirtualMachineError.<init>(VirtualMachineError.java:36)
          01-11 16:00:48.709: I/dalvikvm(18535):   at java.lang.OutOfMemoryError.<init>(OutOfMemoryError.java:34)
          01-11 16:00:48.709: I/dalvikvm(18535):   at java.util.ArrayList.add(ArrayList.java:-1)
          01-11 16:00:48.709: I/dalvikvm(18535):   at org.apache.harmony.xml.dom.ElementImpl.setAttributeNode(ElementImpl.java:329)
          01-11 16:00:48.709: I/dalvikvm(18535):   at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:355)
          01-11 16:00:48.709: I/dalvikvm(18535):   at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:360)
          01-11 16:00:48.709: I/dalvikvm(18535):   at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:133)
          01-11 16:00:48.709: I/dalvikvm(18535):   at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:132)
          01-11 16:00:48.709: I/dalvikvm(18535):   at com.example.simplexmlpullapp.MainActivity.onCreate(MainActivity.java:32)
          01-11 16:00:48.709: I/dalvikvm(18535):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
          01-11 16:00:48.709: I/dalvikvm(18535):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
          01-11 16:00:48.709: I/dalvikvm(18535):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
          01-11 16:00:48.709: I/dalvikvm(18535):   at android.app.ActivityThread.access$1500(ActivityThread.java:123)
         01-11 16:00:48.709: I/dalvikvm(18535):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
         01-11 16:00:48.709: I/dalvikvm(18535):   at android.os.Handler.dispatchMessage(Handler.java:99)
         01-11 16:00:48.709: I/dalvikvm(18535):   at android.os.Looper.loop(Looper.java:130)
         01-11 16:00:48.709: I/dalvikvm(18535):   at android.app.ActivityThread.main(ActivityThread.java:3835)
         01-11 16:00:48.709: I/dalvikvm(18535):   at java.lang.reflect.Method.invokeNative(Native Method)
         01-11 16:00:48.709: I/dalvikvm(18535):   at java.lang.reflect.Method.invoke(Method.java:507)
         01-11 16:00:48.709: I/dalvikvm(18535):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
         01-11 16:00:48.709: I/dalvikvm(18535):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
         01-11 16:00:48.709: I/dalvikvm(18535):   at dalvik.system.NativeStart.main(Native Method)
         01-11 16:00:48.729: W/dalvikvm(18535): Exception thrown (Ljava/lang/OutOfMemoryError;) while throwing internal exception (Ljava/lang/OutOfMemoryError;)
        01-11 16:00:48.729: W/dalvikvm(18535): Could not resolve class ref'ed in exception catch list (class index 349, exception Ljava/lang/OutOfMemoryError;)
        01-11 16:00:49.209: I/dalvikvm-heap(18535): Clamp target GC heap from 25.906MB to 24.000MB
        01-11 16:00:49.209: D/dalvikvm(18535): GC_CONCURRENT freed <1K, 11% free 22006K/24519K, external 3K/514K, paused 5ms+6ms
        01-11 16:00:49.509: D/dalvikvm(18535): GC_FOR_MALLOC freed 19308K, 89% free 2698K/24519K, external 3K/514K, paused 294ms
        01-11 16:00:49.509: D/AndroidRuntime(18535): Shutting down VM
        01-11 16:00:49.509: W/dalvikvm(18535): threadid=1: thread exiting with uncaught exception (group=0x40018560)
        01-11 16:00:49.509: E/AndroidRuntime(18535): FATAL EXCEPTION: main
        01-11 16:00:49.509: E/AndroidRuntime(18535): java.lang.OutOfMemoryError: [memory exhausted]
        01-11 16:00:49.509: E/AndroidRuntime(18535):    at dalvik.system.NativeStart.main(Native Method)
  • 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-17T06:19:32+00:00Added an answer on June 17, 2026 at 6:19 am

    SAX XML Parser in Java

    SAX Stands for Simple API for XML Parsing. This is an event based XML Parsing and it parse XML file step by step so much suitable for large XML Files. SAX XML Parser fires event when it encountered opening tag, element or attribute and the parsing works accordingly. It’s recommended to use SAX XML parser for parsing large xml files in Java because it doesn’t require to load whole XML file in Java and it can read a big XML file in small parts. Java provides support for SAX parser and you can parse any xml file in Java using SAX Parser, I have covered example of reading xml file using SAX Parser here. One disadvantage of using SAX Parser in java is that reading XML file in Java using SAX Parser requires more code in comparison of DOM Parser.

    Difference between DOM and SAX XML Parser
    Here are few high level differences between DOM parser and SAX Parser in Java:

    1) DOM parser loads whole xml document in memory while SAX only loads small part of XML file in memory.

    2) DOM parser is faster than SAX because it access whole XML document in memory.

    3) SAX parser in Java is better suitable for large XML file than DOM Parser because it doesn’t require much memory.

    4) DOM parser works on Document Object Model while SAX is an event based xml parser.

    That’s all on difference between SAX and DOM parsers in Java, now it’s up to you on which XML parser you going to choose. I recommend use DOM parser over SAX parser if XML file is small enough and go with SAX parser if you don’t know size of xml files to be processed or they are large.

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

Sidebar

Related Questions

I am using XMLWriter to create xml.Below is my code which is working fine.
Hello Android programmers, I am working on parsing a website in my application. This
Hello I did login as a super admin in the front en of joomla
I am parsing an XML file through Android Pull Parser technique. First, have a
For example, we have this xml: <x> <y>some text</y> <y>[ID] hello</y> <y>world [/ID]</y> <y>some
i have a xml file and i am parsing it with DOM. ` <media:group>
I am getting this error in my xml file: XML Parsing error: Extra content
I have an XML document with some sample content like this: <someTag> <![CDATA[Hello World]]>
Hello i have trouble with parsing a pdf when the iterator reaches page 11
Hello I have an api response in xml format with a series of items

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.