Getting XML Header in XMLBeans

G

Gugle

Hi All,
I'm using XMLBeans for generating xml files. But it doesn't seem to be
printing the XML Header line at the top - <?xml version="1.0"
encoding="UTF-8"?>. Can someone tell me how to get XMLBeans to add this
to the XML?
 
R

Robert Klemme

Hi All,
I'm using XMLBeans for generating xml files. But it doesn't seem to be
printing the XML Header line at the top - <?xml version="1.0"
encoding="UTF-8"?>. Can someone tell me how to get XMLBeans to add this
to the XML?

You can't - or rather, you should not. I guess that XMLBeans uses
Reader and Writer (i.e. character streams) to read from and write to.
It does not know the encoding of the stream. So you have to write it
yourself.

robert
 
G

Gugle

But I'm setting the encoding type through the XMLOptions object as
follows:

XmlOptions opts = new XmlOptions();
opts.setCharacterEncoding("UTF-8");
//xmlDoc.documentProperties().setEncoding("UTF-8");
xmlDoc.save(writer, opts);

Any idea if XMLBeans will use this value for adding the header?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top