XMLDocument1.Active := true;
XMLDocument1.LoadFromFile( ''temp.xml'' );
TMXMLPersistent.LoadObjFromXML( XMLDocument1.ChildNodes.Last, demo ); 软件开发网
XMLDocument1.Active := false;
Edit1.Text := demo.Company;
Edit2.Text := IntToStr( demo.Code );
While ( demo.Employee.ForEach ) Do
With ListView1.Items.Add Do
Begin
Caption := IntToStr( demo.Employee.EmployeeID );
SubItems.Add( demo.Employee.FirstName );
SubItems.Add( demo.Employee.LastName );
SubItems.Add( FormatDateTime( ''yyyy-mm-dd'', demo.Employee.BirthDate ) );
End;
Finally
demo.Employee.Free;
demo.Employee := Nil;
demo.Free;
End;
end;
终于可以告别那个麻烦的XML Data binding了,并且以后也不用写XSD了--虽然有好用的工具,但能省点事终归是好的。