XML processing Unit xmldoc using Delphi xmlintf
When getting the XML text content, the higher version of Delphi loses the encoding description .... On the D7 is normal, the following is the test source:
Procedure Tform1.button1click (sender:tobject); var nxmldoc:ixmldocument; I:integer; Nms:tmemorystream; Nss:tstringstream; Nstr:string;begin Nxmldoc: = Txmldocument.create (nil); Nxmldoc.active: = True; Nxmldoc.encoding: = ' GB2312 '; Nxmldoc.addchild (' test '); For I: = 0 to 4 do nXMLDoc.DocumentElement.AddChild (' Test '). NodeValue: = i; With Memo1 do begin Lines.clear; Lines.add ('----nXMLDoc.XML.Text----'); Lines.add ("); Lines.add (nXMLDoc.XML.Text); End; NMS: = tmemorystream.create; Nxmldoc.savetostream (NMS); Nms. Position: = 0; With Memo2 do begin Lines.clear; Lines.loadfromstream (NMS); Lines.insert (0, "); Lines.insert (0, '----nxmldoc.savetostream----'); End; Nms.free; Nxmldoc.savetoxml (NSTR); With Memo3 do begin Lines.clear; Lines.add ('----nxmldoc.savetoxml----'); Lines.add ("); Lines.add (NSTR); End;end;
The following is the same code for the execution effect in Delphi7 and Delphi2010 respectively
Comparisons can be found in XML. Text and SaveToXML These 2 methods, on 2010, input later encoding= "GB2312" encoding information will be lost
Version tests that use XE5 are also lost, only normal on D7
Delphi7 Results
Delph2010 Results
Http://www.cnblogs.com/hs-kill/p/3829183.html
A bug about the Delphi XML processing Unit