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

M

mel-tey chamon!

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!
 
M

mel-tey chamon!

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!
 
P

Patrick TJ McPhee

% 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.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top