Database and XML Toolkit
(DbTkXml) Tutorial |
Below you will find a few examples how you can apply DbTkXml:
- Example1 (HTML Export)
- Example2
(XML Export, Edit and Import)
- Example3 (Create a new Query and export)
In this example we will export the "Products"
table from our sample database (sample.mdb)
as a web page in HTML format.
Start the Database Explorer (Start/Programs/Database and XML Toolkit/Database Explorer)
and
right click on the "Products" table and select "Export Data/Web
Page(HTML)":
Once the export completes the confirmation box appears:
Click on the Yes button to view the HTML Export file Products.htm
You can also use the Db2Html utility to export HTML data:
Db2Html -d sample.mdb -t Products
Example2
(XML Export, Edit and Import)
In this example we will export the "Products"
table from our sample database (sample.mdb)
in XML format, edit the data and import the updated XML data into the database.
a) XML Export
Start the Database Explorer (Start/Programs/Database and XML Toolkit/Database Explorer)
and
right click on the "Products" table and select "Export Data/XML
Format":
Click on the Yes button to view the XML Export file Products.xml
in your browser.
You can also use the Db2XML utility to export XML data:
Db2XML -d sample.mdb -t Products
b) XML Edit
To edit the exported file Products.xml click on
"View/Source" in your browser:
b) XML Edit
Then change "Chai" to "Chai 10 by 20":in the NOTEPAD editor
and File/Save and Exit
Click F5 in the browser to refresh and see the new data, then close the browser.
You might install the free XML Editor: Microsoft
XML Notepad (backup)
to directly view and edit XML files!
c) XML
Import
Now we will apply the changes we made in the XML
exported file back into the database:
right click on the "Products" table and select "Import Data/XML
Format":
DbExplorer has automatically suggested "Products.xml" as shown below:
Click on the Open button and the Import will start,
once completed you will see the confirmation box:
DbExplorer will automatically updated the view to show the new data:
You can also use the DbLoad utility to import data:
DbLoad -d sample.mdb -i Products.xml
Example3
(Create a new Query and export)
In this example we will create a new query and export the
data in CSV spreadsheet format.
a) Create new Query
Start the Database Explorer
(Start/Programs/Database and XML Toolkit/Database Explorer) and
right click on the "Queries" item and select "New Query":
In the new Box enter the name "ProductsByPrice"
and the SQL expression:
SELECT DISTINCTROW Products.ProductName, Products.UnitPrice
FROM Products
ORDER BY Products.UnitPrice DESC;
Click on OK to add this new query to the database
and run it.
DbExplorer will display the query result automatically:
products sorted by UnitPrice in descening order (as defined by the SQL
expression above).
You can also use the DbSQL utility to create a new query:
DbSQL -d sample.mdb -i ProductsByPrice.sql -f
CSV
b) Export Data from a Query (CSV)
Right click on the the new "ProductsByTitle" query and select
"Export Data/CSV Format":
Once the CSV Export is completed the confirmation box appears:
Click on YES and your spreadsheet program will display the
exported CSV file:
You can also use the DbQuery utility to export data from a query
DbQuery -d sample.mdb -f CSV -n
ProductsByPrice