sax xmlreader.parse problem

C

curwen

Hi all
I'm trying to use the .parse method accepting only inpustream as parameter,
but I have he xml file in a String (is quite short)

how can I do to pass a string to the xmlreader.parse method?

thanxs in avance
jc
 
S

Sudsy

curwen said:
Hi all
I'm trying to use the .parse method accepting only inpustream as parameter,
but I have he xml file in a String (is quite short)

how can I do to pass a string to the xmlreader.parse method?

thanxs in avance
jc

See java.io.StringReader class.
 
A

Andy Fish

in retrospect I concur with sudsy

your original comment that it only accepts inputStream was not quite
correct. You can also construct a sax InputSource from a reader, so a
StringReader would be the most appropriate solution.
 
C

curwen

the first answer work perfectly! I didn't try the other solution yet.

PS I'm using inputsource too:

ByteArrayInputStream in = new ByteArrayInputStream(fileXML.getBytes());
InputSource source = new InputSource(in);
r.setErrorHandler(new XMLErrorHandler());
r.parse( source );

thanks a lot,
both of you
jc
 

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

Similar Threads


Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top