look at the OTHER parse method of XMLParser (the base-class of DOMParser).
it takes an org.xml.sax.InputSource object which can be wrapped around an
InputStream, a Reader, or a system-id.  try this code instead:

parser.parse(new InputSource(new StringReader(xml)));

HTH.
...............ron.
-----Original Message-----
From: Diego Castillo [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 06, 2001 8:03 AM
To: [EMAIL PROTECTED]
Subject: Problem parsing XML strings with Xerces-J


Hi all,

I have recently started using Xerces-J for parsing XML strings. It works
fine when I have a file to parse, but I don't know how to parse a String.
Currently I write down my String into a file and feed the parser with that
file. I suppose that it is possible to directly feed the String, but I don't
know how. Can anybody help me?

Thanks in advance,


Diego Castillo

______________________________________________________

void parse(String xml) {
  try {

    File f = File.createTempFile("", ".xml");
    FileOutputStream fout = new FileOutputStream(f);
    fout.write(xml.getBytes());
    fout.flush();
    fout.close();

    DOMParser parser = new DOMParser();
    parser.reset();
    parser.parse(f.getAbsolutePath());
    Document doc = parser.getDocument();

  } catch (Exception e) { }
}
______________________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to