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/del/archive/2008/01/03/1024883.html
作者:黄聪
出处:http://www.cnblogs.com/huangcong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://www.cnblogs.com/huangcong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。