how to read XML?
hi, i am passing a string as below to my program.
<PERSON><id>1</id><country>Australia</country></PERSON>
but how to read this string to get the id and country? i have done by write it to a file.xml and read it. but can it done by no need write to file and read it? anyone can giv me a simple example? thanks
[345 byte] By [
gracebabya] at [2007-11-27 11:09:05]

> hi, i am passing a string as below to my program.
> <PERSON><id>1</id><country>Australia</country><> PERSON>
> but how to read this string to get the id and
> country? i have done by write it to a file.xml and
> read it. but can it done by no need write to file and
> read it? anyone can giv me a simple example? thanks
Create a Document object from an InputStream rather than from a file.
Here's something I found:
http://www.bubble-media.com/cgi-bin/articles/archives/000038.html
public java.io.InputStream parseStringToIS(String xml){
if(xml==null) return null;
xml = xml.trim();
java.io.InputStream in = null;
try{
in = new java.io.ByteArrayInputStream(xml.getBytes("UTF-8"));
}catch(Exception ex){
}
return in;
}