在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, xmldom, XMLIntf, msxmldom, XMLDoc, StdCtrls; type TForm1 = class(TForm) XMLDocument1: TXMLDocument; Button1: TButton; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} //打开 procedure TForm1.FormCreate(Sender: TObject); begin XMLDocument1.LoadFromFile('c:\temp\test.xml'); {必须用万一提供的 xml 测试文件, 才能有相同的返回值} end; //一个多余的属性: Nodes procedure TForm1.Button1Click(Sender: TObject); var node: IXMLNode; begin node := XMLDocument1.DocumentElement.ChildNodes[0]; ShowMessage(node.ChildNodes[0].NodeValue); {张三} ShowMessage(node.ChildNodes.Nodes[0].NodeValue); {张三} ShowMessage(node.AttributeNodes[0].NodeValue); {科长} ShowMessage(node.AttributeNodes.Nodes[0].NodeValue); {科长} end; end. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论