在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls, OleCtrls, SHDocVw; type TForm1 = class(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. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论