[jdom-interest] RE: Getting xml header for every input into xml file

Edelson, Justin Justin.Edelson at mtvn.com
Fri Oct 27 08:18:15 PDT 2006


>I got your point but it wont print xml header at all,
>the problem is xml version is printed for every entry in the 
>xml file as
>shown below.
>
><?xml version="1.0" encoding="UTF-8"?>
><root><name>Mukunda</name><age>26</age></root>
><?xml version="1.0" encoding="UTF-8"?>
><root><name>a</name><age>30</age></root>
>
>I dont want to print version headers to each and every input.
>

Why do you want to have a false declaration -- the document isn't XML
1.0, so why claim it to be?

If you insist on including an XML declaration in an invalid file, you
could just have a boolean that you switch after writing the first
document and then use that boolean to determine how to create a new
XMLOutputter. But I have to say that I (and I suspect others) think this
is a bad idea. You should either produce valid XML or admit that what
you're doing isn't XML. There's a reason standards exist.

Justin



More information about the jdom-interest mailing list