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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:53:44+00:00 2026-06-06T19:53:44+00:00

I am using saxparser in order to get xml tag contents from file. All

  • 0

I am using saxparser in order to get xml tag contents from file. All works properly for a non long data xml. However, when arribed at certain position, characters() event received truncated ch[] and is triggered twice. For example for 1234567890 is received twice and value is truncated like following example. How to clear char array or memory?

id  1234567890
name myName1
id  1234567890
name myName2
...
(error)
id 1234567
id 890
name myName3

Code:

private StringBuffer buf = new StringBuffer(2048);

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

            if(this.v_Id){

                buf.append(ch, start, length);

                myParsedXMLDataSet.setId(buf.toString());

                Log.d("id", buf.toString());

                buf.delete(0, buf.length());

            }
  • 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-06T19:53:46+00:00Added an answer on June 6, 2026 at 7:53 pm

    characters() is allowed to be called multiple time for the same element (see documentation). You should not assume that it will only be called once, even though most time that is the case. Append to the buffer each time characters() is called, then store the value when endElement() is called.

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

Sidebar

Related Questions

In order to get XML data from a server repeatedly, I'm attempting to use
Respected All, I have to read XML file, for that I use SAXParser and
I am using SAX to parse an XML file I'm pulling from the web.
I need to read read values from below xml and am using saxparser for
I am using SAX Parser to parse XML data from a http url. I
I am using SAXParser and the characters after any Apostrof(') in the xml file
hi i am trying to parse an xml file using SAXparser. I followed the
Thanks for previous replies. I am parsing XML file using java(SAXParser), i am not
I'm parsing a big XML file using SAXParser in Android and was wondering if
I am trying to get xml file from url link . This code for

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.