xml - Why does TXmlDocument omit the encoding when I serialize to a string? -


if build xml line line, can set encoding, when load file, cannot add encoding. see:

procedure tform1.button1click(sender: tobject); var     x : txmldocument;     s : string;     w : widestring; begin     s := '<?xml version="1.0"?><a><b/></a>';     x := txmldocument.create(self);     x.xml.text := s;     x.active := true;     x.encoding := 'utf-8';     x.documentelement.childnodes['b'].attributes['x'] := '1';     x.savetoxml(w);     showmessage(w); end; 

interesting "encoding" part missing result!

how make result contain xml encoding?

you’re saving xml widestring. widestring is, definition, utf16-encoded, there’s no point whatsoever in specifying encoding. iirc, can specify encoding="utf-16", won’t removed, since that’s is.

you can, however, specify different encoding if consequently save xml document stream.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -