Newbie question : Xerces (C++) How do I create the <?xml version="1.0" encoding="UTF-8" ?> header

Discussion in 'XML' started by mel-tey chamon!, May 14, 2004.

  1. I have created a XML Writer program, and everything works, but I need to
    revice my code and add this "version and encoding" header for completeness
    and correctness... I am completely stuck!

    I have done this so far:

    DOM_Element root = xmlDoc.getRootElement();
    root.setAttributes ("xmlns","etc.etc.");

    Do I have to previous root called "?" - but this doesn't make much sense as
    the tag begins "<?xml" and ends "?>"

    From scouring the web, I believe that I coding with a legacy version of
    xerces-c. (hence DOM_Element)
    I cannot change or update the library

    Please can I have a snippet of code?

    Thanks a lot!
    mel-tey chamon!, May 14, 2004
    #1
    1. Advertising

  2. I hope this reads a bit nicer: Hands moving quicker than brain(!)

    I have created a XML Writer program, and everything works, but I need to
    revise my code and add this "version and encoding" header for completeness
    and correctness... I am completely stuck!

    I have done this so far:

    DOM_Element root = xmlDoc.getRootElement();
    root.setAttributes ("xmlns","etc.etc.");

    Do I have to create another previous root called "?" - but this doesn't make
    much sense as the tag begins "<?xml" and ends "?>"

    From scouring the web, I believe that I coding with a legacy version of
    xerces-c. (hence DOM_Element): I cannot change or update the library

    Please can I have a snippet of code?

    Thanks a lot!
    mel-tey chamon!, May 14, 2004
    #2
    1. Advertising

  3. In article <c8225m$nat$>,
    mel-tey chamon! <nose_pam@nose_pam.com> wrote:

    % I have created a XML Writer program, and everything works, but I need to
    % revice my code and add this "version and encoding" header for completeness
    % and correctness... I am completely stuck!

    This is called the XML declaration. It's not an element. There should
    be an attribute on the document class which says whether to write the
    XML declaration, though.

    --

    Patrick TJ McPhee
    East York Canada
    Patrick TJ McPhee, May 16, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page