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

lucatony_22

New Member
If I build an XML from line to line, I can set the encoding, but when I load it from file, I cannot add the encoding. See:\[code\]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;\[/code\]Interesting that the "encoding" part is missing from the result!How do I make the result contain the XML encoding?
 
Back
Top