Getting XML Header in XMLBeans

Discussion in 'Java' started by Gugle, Dec 20, 2006.

  1. Gugle

    Gugle Guest

    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?
     
    Gugle, Dec 20, 2006
    #1
    1. Advertisements

  2. 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
     
    Robert Klemme, Dec 20, 2006
    #2
    1. Advertisements

  3. Gugle

    Gugle Guest

    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?
     
    Gugle, Dec 20, 2006
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.