You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Matt Movafaghi <ma...@aspectdv.com> on 2000/08/22 18:38:29 UTC

Reading from a string??

How would I configure th DOM parser to read from a string instead of a file?

Thanks, matt


RE: Reading from a string??

Posted by "Longstrom, Ed" <lo...@AtlasCommerce.com>.
Probably a really bad example, but it works.


strXML = your xml in a string

         StringReader sre = new StringReader(strXML);
         InputSource sr = new InputSource(sre);
         StringWriter out = new StringWriter();

	 // Use a DOMParser from Xerces so we get a complete DOM from the document
      DOMParser parser = new DOMParser();


      try
      {
        parser.parse(sr);
      }
      catch(Exception e1)
      {
        System.err.println("Parsing " + strXML + " threw: " +
e1.toString());
        e1.printStackTrace();
        return("");
      }

> -----Original Message-----
> From: Matt Movafaghi [mailto:mattm@aspectdv.com]
> Sent: Tuesday, August 22, 2000 12:38 PM
> To: xerces-j-dev@xml.apache.org
> Subject: Reading from a string??
>
>
> How would I configure th DOM parser to read from a string instead
> of a file?
>
> Thanks, matt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org