unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls;
type
TForm1 = class (TForm)
XMLDocument1: TXMLDocument;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
end ;
var
Form1: TForm1;
implementation
{ $R *.dfm }
// 读取或设置 xml 的编码与版本号
procedure TForm1.FormCreate(Sender: TObject);
begin
XMLDocument1.LoadFromFile( ' c:\temp\test.xml ' );
ShowMessage(XMLDocument1.Version); { 1.0 }
ShowMessage(XMLDocument1.Encoding); { gb2312 }
{ 另外, 这两个属性都是可写的, 譬如: }
XMLDocument1.Encoding : = ' UTF-8 ' ;
Memo1.Lines : = XMLDocument1.XML; { 这时会显示乱码 }
end ;
end .
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls;
type
TForm1 = class (TForm)
XMLDocument1: TXMLDocument;
Memo1: TMemo;
procedure FormCreate(Sender: TObject);
end ;
var
Form1: TForm1;
implementation
{ $R *.dfm }
// 读取或设置 xml 的编码与版本号
procedure TForm1.FormCreate(Sender: TObject);
begin
XMLDocument1.LoadFromFile( ' c:\temp\test.xml ' );
ShowMessage(XMLDocument1.Version); { 1.0 }
ShowMessage(XMLDocument1.Encoding); { gb2312 }
{ 另外, 这两个属性都是可写的, 譬如: }
XMLDocument1.Encoding : = ' UTF-8 ' ;
Memo1.Lines : = XMLDocument1.XML; { 这时会显示乱码 }
end ;
end .
本文转自黄聪博客园博客,原文链接:http://www.cnblogs.com/huangcong/archive/2010/08/27/1809945.html,如需转载请自行联系原作者