Thank you - that's exactly the help I needed!

Cheers

Tim

-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Andrea Foster
Sent: 28 March 2001 11:37
To: [EMAIL PROTECTED]
Subject: Re: XML,Servlet, Parser Prob


Hi

yes, kinda offtopic, but here's an answer.....

I use xerces and came up with the following:

if you look at the InputSource constructors you will see that you can
pass it a StringReader... and a StringReader has a constructor that you
can pass a String....

<snip>
String theXML;
theXML = httpservletrequest.getParameter("xml");
if (theXML == null) {
         // houston, we have a problem
} else{
        // do stuff with the xml
        try {
            XMLReader xr = XMLReaderFactory.createXMLReader();
            MyHandler  handler = new MyHandler();
            xr.setContentHandler(handler);
            xr.setErrorHandler(handler);
            StringReader sr = new StringReader(theXML);
            xr.parse(new InputSource(sr));
        }
        }catch (SAXException se){
          //dostuff

        }catch (IOException ioe){
           //do stuff
        }
}

<snip>

Ms Andrea Foster

Analyst Programmer
Unibase Development
tel : 021 414 4715
fax : 021 418 1288
cell : 082 516 0277

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to