Retrieving Data to XML


Create an SQL::Connection object, select data from a server, and convert it to XML.

You can select data from a server and convert it to XML. First, create a SQL::Connection object.

dim conn as SQL::Connection
dim data as C
dim qry as C
qry = "SELECT * FROM customers"

Open the connection. In the example below, we are using the AADemo-Northwind connection string, which can be created from the AlphaDAO Connections dialog in Alpha Anywhere.

= .T.

Get the data. The [SQL::Connection toXML] function will retrieve the query results and format them as an XML object.

data = conn.ToXML(qry)

The first few lines of the generated XML along with the first record are shown below:

? data
		<CompanyName>Alfreds Futterkiste</CompanyName>
		<ContactName>Maria Anders</ContactName>
		<ContactTitle>Sales Representative</ContactTitle>
		<Address>Obere Str. 57</Address>

After data has been retrieved, close the connection.


See Also