You have to initialise an OutputFormat object and pass it to the serialiser.
You set the Doctype declaration and other things like indentation in the
OutputFormat.

Arnaud Le Hors wrote:

> The documentation is really sparse on this so maybe I'm just using it in
> a way which is not intended but it appears to me that using the same
> serializer for more than one document fails.
>
>      XMLSerializer serializer = new XMLSerializer(System.out, null);
>      System.out.println("Doc1:");
>      serializer.serialize(doc1);
>      System.out.println("Doc2:");
>      serializer.serialize(doc2);
>
> gives:
>
> Doc1:
> <?xml version="1.0"?>
> <el1><el1.2/></el1>
> Doc2:
> <el2><el1.1 a1="v1" a2="v2"><el1.1.1/></el1.1></el2>
>

Reply via email to