Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Import from XML into a Table


This question is answered.


Permlink Replies: 3 - Last Post: Mar 3, 2016 9:12 PM Last Post By: Melissa Torn
Melissa Torn

Posts: 143
Registered: 4/30/09
Import from XML into a Table  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 3, 2016 5:17 AM
- I export the datas of a table to an XML file
- I empty ( delete all records ) the table
now I want to add the XML records which i exported
in to the empty Table
What is the shortest way ?

Thank You
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Import from XML into a Table  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 3, 2016 6:46 AM   in response to: Melissa Torn in response to: Melissa Torn
- I export the datas of a table to an XML file
How?
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Import from XML into a Table
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 3, 2016 7:29 AM   in response to: Melissa Torn in response to: Melissa Torn
Delphi has a very cool XML interface builder:

Click: File-New-Other..
Click: Delphi Projects Tree - XML.
Select: XML Data Binding.

Select your XML (change filetype in open dialog) and create the Interface Unit. (Just next-next-next-..)

Use the Interface like:
(example a book.xml created a book.pas)

uses book.pas;
 
var MyXML : IXMLCatalogType;
    MyBook: IXMLBookType;
    idxCatalog: Integer;
begin
  MyXML := Loadcatalog('book.xml');
  for idxCatalog:=0 to MyXML.Count-1 do
  begin
    MyBook:= MyXML.Book[idxCatalog];
    myTable.Insert;
    myTable.fieldbyname('Author').AsString:=MyBook.Author;
    //all fields..
    myTable.Post;
  end;
end;
Melissa Torn

Posts: 143
Registered: 4/30/09
Re: Import from XML into a Table  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 3, 2016 9:12 PM   in response to: Robert Triest in response to: Robert Triest
Thank you so very much Robert
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02