20 Mayıs 2017 Yazarı yhackup 0

Delphi ile DataSet To XML

Var
 XML : IXMLDOCUMENT;
 PolisoftXMLExport,TabloName,Field:IXMLNODE;
 i,a:integer;
begin
  if  Data.IsEmpty then
  begin
    ShowMessage('DataSet is not null');
    Exit;
  end;
 XML := NewXMLDocument;
 XML.Encoding  := 'utf-8';
 XML.Options   := [doNodeAutoIndent];
 PolisoftXMLExport      := XML.AddChild('PolisoftXMLExport');
  for I := 1 to Data.RecordCount do
    begin
      TabloName := PolisoftXMLExport.AddChild('Police',i);
       Data.First;
       for a := 1 to Data.FieldCount do
         begin
            Field := TabloName.AddChild(Data.Fields[a-1].FieldName,0);
                 Field.Text := Data.Fields[a-1].AsString;
         end;
    end;
 XMl.SaveToFile(Path);
 ShellExecute(HANDLE_FLAG_INHERIT,'open',PAnsiChar(Path),nil,nil,SW_HIDE); 
 
end