Title: RE: Problem parsing XML strings with Xerces-J

use DocumentBuilder.parse(new InputSource(new StringReader(<the xml string>))

    -----Original Message-----
    From:   Diego Castillo [SMTP:[EMAIL PROTECTED]
    Sent:   Tuesday, November 06, 2001 11: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]

Reply via email to