DelphiのXMLDocumentクラスの詳細(16)-ノードリストの最初のノードと最後のノード
1178 ワード
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);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
XMLDocument1.LoadFromFile('c:\temp\test.xml');
{ xml , }
end;
//
procedure TForm1.Button1Click(Sender: TObject);
var
nodeList: IXMLNodeList;
node: IXMLNode;
begin
nodeList := XMLDocument1.DocumentElement.ChildNodes[2].ChildNodes;
{ nodeList }
// :
node := nodeList.First; {First}
ShowMessage(node.NodeValue); { }
// :
node := nodeList.Last; {Last}
ShowMessage(node.NodeValue); {25}
end;
end.