Hello,

you can give the SAXBuilder a StringReader as Parameter:
Document doc = builder.build(new StringReader(strXml));


> -----Ursprüngliche Nachricht-----
> Von:  Mayuresh Kadu [SMTP:[EMAIL PROTECTED]]
> Gesendet am:  Donnerstag, 22. Februar 2001 20:48
> An:   [EMAIL PROTECTED]
> Betreff:      JDom in a Servlet ?
>
> I am using a Servlet to recv a XML string as a post from a form and i
> wanna
> simply parse it to get hold of the vars.
>
> the code i am using is
>
>         String strXml;
>
>         strXml = request.getParameter("strMessage");
>
>         try {
>                 // Request document building without validation
>
>                         SAXBuilder builder = new SAXBuilder(false);
>                 Document doc = builder.build(strXml);
>
>                 Element root = doc.getRootElement();
>
>                 String strName = root.getChildText("Name");
>
>                         PrintWriter out = response.getWriter();
>
>                         response.setContentType("text/html");
>                         out.println("<html>");
>                         out.println("Name = " + strName );
>                         out.println("</html>");
>
>         }
>         catch( Exception e ) {
>                 System.out.println( e );
>
>         }
>
>
> the exception i get is
>
> org.jdom.JDOMException: Error on line 0: File "<message><Name>Shailesh
> Khandkar</Name><message>"
>
> Now i undrstand that the line
>
>                         SAXBuilder builder = new SAXBuilder(false);
>                 Document doc = builder.build(strXml);
>
> is causing the problem as SaxBuilder takes a filename to build JDOM frm as
> a
> param. However, i have only a string .. what do i do ?
>
>
> Mayuresh
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.231 / Virus Database: 112 - Release Date: 02/12/2001
>
> ==========================================================================
> =
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
> DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to