procedure TForm1.btn2Click(Sender: TObject);//读取
VAR
STOCKNODE:IXMLNode;
begin
xmldocument1.Create('D:/test.xml');
XMLDocument1.Active:=TRUE;
//STOCKNODE := XMLDocument1.DocumentElement.ChildNodes[0];
// edt1.Text := STOCKNODE.ChildNodes['length'].Text;
edt1.Text:=XMLDocument1.DocumentElement.ChildNodes[0].ChildNodes[0].Text;
XMLDocument1.
XMLDocument1.Active:=FALSE;
end;
procedure TForm1.btn3Click(Sender: TObject);//创建
VAR
xml:TXMLDocument;
node:IXMLNode;
begin
Xml:= TXMLDocument.Create(nil);
Xml.active:=true;
xml.DocumentElement:=xml.CreateNode('XMLPacage');
node:=xml.CreateNode('memo');
xml.DocumentElement.ChildNodes.Add(node);
node.ChildNodes.Add(xml.CreateNode('Hello! I am yaya!',ntText));
node.AttributeNodes.Add(xml.CreateNode('length',ntAttribute));
node.SetAttribute('length',16);
node.AttributeNodes.Add(xml.CreateNode('color',ntAttribute));
node.SetAttribute('color',$0034494B);
node.AttributeNodes.Add(xml.CreateNode('wid',ntAttribute));
node.SetAttributeNS('wid','',IntToStr(123456));
xml.SaveToFile('d:/test.xml');
xml.Active:=false;
end;