Reading Data into an XML Stream

If you know the table names and field names, it is a simple matter to construct an XML file from the recordset.

Again, the strategy in this section is to provide a simple example of an ASP page that connects to biblio.mdb and reads one of the tables into an XML file, and then to analyze the code.

The following listing of connect2.asp will connect to the biblio.mdb database and open the publishers table. It will then create an XML file called bib_pub.xml and read the PubId, telephone, and name fields for each record into the XML file. It will do this by iterating through the records and writing the following line of XML for every record:

<publisher> <PubId> [value] </PubId> <name>[value] </name> <telephone>[value] ...

Get XML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.