专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »PHP教程 » .netxmldocument:Delphi 中的 XMLDocument 类详解(18) - 更好地显示 xml 的测试结果 - FormatXMLData 及其他 »正文

.netxmldocument:Delphi 中的 XMLDocument 类详解(18) - 更好地显示 xml 的测试结果 - FormatXMLData 及其他

来源: 发布时间:星期一, 2009年11月30日 浏览:0次 评论:0
unit Unit1; 
 
erface 
 
uses 
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
 Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls, OleCtrls, SHDocVw; 
 
type 
 TForm1 = (TForm) 
  Button1: TButton; 
  Button2: TButton; 
  Button3: TButton; 
  XMLDocument1: TXMLDocument; 
  Memo1: TMemo;       {Memo} 
  WebBrowser1: TWebBrowser; {WebBrowser} 
  procedure FormCreate(Sender: TObject); 
  procedure Button1Click(Sender: TObject); 
  procedure Button2Click(Sender: TObject); 
  procedure Button3Click(Sender: TObject); 
 end; 
 
var 
 Form1: TForm1; 
 
implementation 
 
{$R *.dfm} 
 
uses ShellAPI; {为提供 ShellExecute } 
 
//打开 
procedure TForm1.FormCreate(Sender: TObject); 
begin 
 XMLDocument1.LoadFromFile('c:\temp\test.xml'); 
end; 
 
 
// xml 格式化输出, 通过 Memo 显示 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
 Memo1.Lines.Text := FormatXMLData(XMLDocument1.XML.Text); 
 {TXMLDocument 所在 XMLDoc 单元给我们提供了 xml 格式化 FormatXMLData} 
end; 
 
 
//先保存修改结果, 通过 WebBrowser 会有更好显示效果 
procedure TForm1.Button2Click(Sender: TObject); 
begin 
 XMLDocument1.SaveToFile('c:\temp\test2.xml'); 
 WebBrowser1.Navigate('c:\temp\test2.xml'); 
end; 
 
 
//先保存, 然后用外部浏览器显示, 需要 uses ShellAPI 单元 
procedure TForm1.Button3Click(Sender: TObject); 
begin 
 XMLDocument1.SaveToFile('c:\temp\test2.xml'); 
 ShellExecute(Handle, 'open', 'Explorer.exe', 'c:\temp\test2.xml', nil, SW_SHOWNORMAL); 
end; 
 
end. 


标签:.netxmldocument
0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: