gulya2005
11th November 2010, 08:24
How I can to indicate on writing xml file "encoding"?
I want to get:
<?xml version ="1.0" encoding="UTF8"?>,
Now I have:
<?xml version ="1.0" >.
Thank you.
goooch
11th November 2010, 08:59
Hi,
I think it's impossible if you will use only BAAN XML. It is a restrictrion of XML generator
A fixed XMLDecl is generated. This declaration is always: <?xml version="1.0"?>
And one more restriction
The output encoding is always UTF-8
Other interesting constraints can be found in H1004 EN-US
Best Regards,
Goooch
vahdani
11th November 2010, 10:52
Hi,
I once had to do this. My Solution was to write.pretty the XML to a temporary file and read back the file and replace the first line. You could also write to a string and change the string...
marnix
17th November 2010, 16:05
Why do you want to add the encoding declaration?
Functionally, since xmlWrite() always generates UTF-8, and never starts its output with a UTF-16 byte order mark, the declarations <?xml version="1.0"?> and <?xml version="1.0" encoding="UTF-8"?> are equivalent. So there should be no need to add the encoding="UTF-8" part...
Background: The XML specification says that "it is a fatal error [...] for an entity which begins with neither a Byte Order Mark nor an encoding declaration to use an encoding other than UTF-8." See http://www.w3.org/TR/REC-xml/#charencoding.