Problem with characters() method in java SAX DefaultHandler

W

Wes Batson

I am trying to parse data from the following xml file:

<?xml version+"1.0"?>
<Data>
<coName>Company Name</coName>
<coAdd>Company Address</coAdd>
</Data>

Here is my characters() method:

public void characters(char[] ch, int start, int length) throws
SAXException{
stringarray[position] = new String(ch, start, length);
}

Later I print out the stringarray. I have seen in every example that
overriding the characters() method should grab the data inside the
tags. However, I have noticed that when characters() is called each
time the char[] ch is an empty string. I was curious if anyone has
had this problem before.

Thanks in advance,

WWB
 
G

Guest

I am trying to parse data from the following xml file:

<?xml version+"1.0"?>
<Data>
<coName>Company Name</coName>
<coAdd>Company Address</coAdd>
</Data>

Here is my characters() method:

public void characters(char[] ch, int start, int length) throws
SAXException{
stringarray[position] = new String(ch, start, length);
}
}

FYI, a single call to characters may or may not contain all the characters
between tags. Many parsers use a StringBuffer then Stringify it when the
tag is closed.

La'ie Techie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top