1

I have a problem when I try converter a document (org.w3c.dom.Document) to String for GWT.

Bofer I developed it without to use GWT and I make like this:

        XMLSerializer xmlSerializer = new XMLSerializer();
        StringWriter strWriter = new StringWriter();
        OutputFormat outFormat1 = new OutputFormat();

        outFormat1.setEncoding("UTF-8");
        //outFormat1.setEncoding("ISO-8859-1");
        outFormat1.setVersion("1.0");
        outFormat1.setIndenting(true);

        outFormat1.setIndent(4);
        //outFormat1.setIndent(2);
        outFormat1.setOmitXMLDeclaration(false);

        outFormat1.setMethod("xml");


        xmlSerializer.setOutputCharStream(strWriter);
        xmlSerializer.setOutputFormat(outFormat1);
        xmlSerializer.serialize(xmlDoc);
        strWriter.close();

But the application give a mistake because GWT don´t accept it.

Do someone know some other solution?

Thanks.

1 Answer 1

1

I guess you are trying to deal with xml documents in client side, right?

If so, you cannot use org.w3c.dom since it is not part of the subset of the java runtime library emulated by gwt.

To handle xml in client-side you have to use GWT XML parsers, or another client library, personally I prefer the gwtquery XML data-binding way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.