delphi的xml基本解析

procedure TForm1.btn1Click(Sender: TObject);

var
    a : TXMLDocument;
    b : string;
    Root,CNode:IXMLNode;
begin
    a:=TXMLDocument.Create(self);
    a.FileName:= 'http://localhost/Student.xml';
    a.Active:=true;
    Root := a.DocumentElement;
    CNode :=  Root.ChildNodes.First ;
    while CNode <> nil do
    begin
    b:=CNode.ChildNodes['name'].Text;
    b:=b+'='+ CNode.ChildNodes['age'].Text;
    showmessage(b);
    CNode :=  CNode.NextSibling;
    end;
    a.Free;


end;



<ROOT>
<Student> 
    <name> zhang </name> 
    <age> 21 </age> 
</Student>
<Student> 
    <name> zhang2 </name> 
    <age> 213 </age> 
</Student>
<Student> 
    <name> zhang3 </name>
    <age> 34 </age>  
</Student>
<Student> 
    <name> zhang4 </name>
</Student>
<Student> 
    <name> zhang5 </name>
    <age> 23</age>
    <type>靠靠</type>
</Student>
</ROOT>

你可能感兴趣的:(数据结构,xml,框架,F#,Delphi)