Parsing a String of XML with Jakarta Commons Digester

W

Wendy S

I have a String of XML, say:

String data = "<person><key>012345</key><preferredName>Amy
Johnson</preferredName></person>"

I'm trying to feed it to Digester's parse
method(http://jakarta.apache.org/commons/digester/api/org/apache/commons/dig
ester/Digester.html) and my choices are:

parse(java.io.File file)
parse(org.xml.sax.InputSource input)
parse(java.io.InputStream input)
parse(java.io.Reader reader)
parse(java.lang.String uri)

I'm still wandering around the API. So far, I think I will have to take my
String, turn it into a byte[], make a ByteArrayInputStream and then
(finally) call the third option above, parse(java.io.InputStream input).

Is there a better way to do it?

Thanks in advance,
 
C

Collin VanDyck

Wendy said:
I have a String of XML, say:

String data = "<person><key>012345</key><preferredName>Amy
Johnson</preferredName></person>"

I'm trying to feed it to Digester's parse
method(http://jakarta.apache.org/commons/digester/api/org/apache/commons/dig
ester/Digester.html) and my choices are:

parse(java.io.File file)
parse(org.xml.sax.InputSource input)
parse(java.io.InputStream input)
parse(java.io.Reader reader)
parse(java.lang.String uri)

I'm still wandering around the API. So far, I think I will have to take my
String, turn it into a byte[], make a ByteArrayInputStream and then
(finally) call the third option above, parse(java.io.InputStream input).

Is there a better way to do it?

Thanks in advance,

Try parse(new StringReader(data));
 

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
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top