DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Missing bytes with JAVA SAX Parser

  1. #1
    Join Date
    Sep 2006

    Missing bytes with JAVA SAX Parser

    I am using JAVA SAX parser to parse a XML file and write the contents to a text file. When the XML file size is small, my program is working fine and contents are retreived correctly but when the XML file size is big (the file size I got the problem with is 1MB), few bytes are missing in contents randomly.

    XML file:


    When parsed the file with above records,
    content in <PayIdNum> is extracted as 789 for few records,
    content in <Sender> is extracted as ER for few redords and
    for few other records Date fields as 060101.

    Number of records missing the bytes is very less in comparision with the total number of records in the file, for a XML file with 2100 records this problem happened to only 10 records.

    when debugged the program:

    public void characters(char[] ch, int start, int len) throws SAXException {
    String str=new String(ch, start, len);
    in this methos for <PayIdNum> it showed len=3, start=0 and str=789;
    actual size of this field is 9, it showed the same size for all other records but only for the bytes missing records it showed the length lesser than the actual length.

    I did not get any clue where else I need to check when parser itself is showing the wrong character array size.

    Any help on this problem please? it's an urgent requirement.

  2. #2
    Join Date
    Nov 2006

    Missing data using SAX parser

    You need add each chunk of data given in the characters(char[], int, int) event callback.

    The javadoc states:

    "The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks"

    In the endElement() method, reset the accumulated string.

Similar Threads

  1. Replies: 2
    Last Post: 06-14-2006, 03:16 PM
  2. Java vs. .Net. A questionnaire
    By Basil in forum .NET
    Replies: 1
    Last Post: 05-13-2005, 06:46 AM
  3. DevX does seem one sideded
    By Rob Abbe in forum Talk to the Editors
    Replies: 44
    Last Post: 01-13-2003, 03:57 PM
  4. learning c# very confusing.
    By Mike Tsakiris in forum .NET
    Replies: 11
    Last Post: 10-04-2002, 05:32 PM
  5. Re: VB vs. Visual Age for Java
    By JJ in forum Enterprise
    Replies: 1
    Last Post: 07-06-2000, 04:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center