Ciao,
innanzitutto grazie del suggerimento.
Ho provato come di seguito
import org.xml.sax.*;
import org.xml.sax.helpers.*;
import java.util.*;
class HowToHandler extends DefaultHandler {
boolean nome = false;
boolean valore = false;
int x,y=0;
int i;
private Vector<String> fileItems = new Vector<String>();
StringBuffer buf = new StringBuffer();
/* public void characters(char[] ch, int start, int length)
{
buf.append(ch, start, length);
}*/
public void startElement(String nsURI, String strippedName, String tagName,
Attributes attributes) throws SAXException {
if ( tagName.equalsIgnoreCase("Name") )
nome = true;
if ( tagName.equalsIgnoreCase("Val") )
valore = true;
}
public void characters(char [] ch, int start, int length) {
if ( nome ) {
buf.append(ch, start, length);
//addElement((new String(ch, start, length)));
fileItems.addElement(buf.toString());
System.out.println("Prova:" + fileItems.get(x));
x++;
nome = false;
}
else
if ( valore )
{
//fileItems.addElement((new String(ch, start, length)));
buf.append(new String(ch, start, length));
fileItems.addElement(buf.toString());
System.out.println("PLuto:" + fileItems.get(x));
x++;
valore = false;
// x++;
}
}
public Vector getFileItems ()
{
return fileItems;
}
}
ma ho un Exception:java.lang.ArrayIndexOutOfBoundsException :
apena finisco il parse.
Sai mica cosa possa essere?