I have a string input from which I need to extract simple information, here is the sample xml (from mkyong):
&l
You call parse with a String
as the first parameter. According to the docu that string is interpreted as the URI
to your file.
If you want to parse your String
directly, you have to transform it to an InputStream
in the first place for usage with the parse(InputSource is, DefaultHandler dh)
method (docu):
// transform from string to inputstream
ByteArrayInputStream in = new ByteArrayInputStream(xml.toString().getBytes());
InputSource is = new InputSource();
is.setByteStream(in);
// start parsing
saxParser.parse(xml.toString(), handler);