SQL::ConnectionToXML Method
Syntax
Arguments
- SQLStatementCharacter
SQL SELECT statement.
- ArgumentsSQL::Arguments
A SQL::Arguments object. One or more arguments to be resolved when the SELECT statement is executed.
- RowsToCopyNumeric
Default = -1 (all). The number of rows to copy.
- StartRowNumeric
Default = -1 (first). The first row to copy.
- documentnameCharacter
The tag for the document element. See example.
- rownameCharacter
The tag for the row element. See example.
- headerCharacter
The tag for the header element. See example.
- ColumnReferencesSQL::TableInfo
A SQL::TableInfo object. When data is formatted for a column in the result set: (1) if ReferenceColumns has a column with a matching name, that object will be used to format the data; (2) otherwise the ColumnInfo property of the result set is used to format the data.
- UserContextPointer
The user context is passed into the evaluation of the expression when data is formatted.
Returns
- XML_StringCharacter
An XML version of the retrieved data.
Description
Fetch data to an XML formatted string using a SQL query.
Discussion
The ToXML() method fetches data to an XML formatted string using a SQL query.
Example
dim connString as C dim args as SQL::Arguments dim select_exp as C dim data as C select_exp = "select CustomerID, City, Region from Customers WHere country = 'USA'" if .not. conn.open("::Name::AADemo-Northwind") then end end if if .not. conn.execute(select_exp) then end end if data = conn.toxml(select_exp, args, -1, 1, "DocName", "RowName", "HeaderName") conn.close()
The XML data looks like this:
HeaderName <DocName> <RowName> <CustomerID>GREAL</CustomerID> <City>Eugene</City> <Region>OR</Region> </RowName> <RowName> <CustomerID>HUNGC</CustomerID> <City>Elgin</City> <Region>OR</Region> </RowName> <RowName> <CustomerID>LAZYK</CustomerID> <City>Walla Walla</City> <Region>WA</Region> </RowName> <RowName> <CustomerID>LETSS</CustomerID> <City>San Francisco</City> <Region>CA</Region> </RowName> <RowName> <CustomerID>LONEP</CustomerID> <City>Portland</City> <Region>OR</Region> </RowName> <RowName> <CustomerID>OLDWO</CustomerID> <City>Anchorage</City> <Region>AK</Region> </RowName> <RowName> <CustomerID>RATTC</CustomerID> <City>Albuquerque</City> <Region>NM</Region> </RowName> <RowName> <CustomerID>SAVEA</CustomerID> <City>Boise</City> <Region>ID</Region> </RowName> <RowName> <CustomerID>SPLIR</CustomerID> <City>Lander</City> <Region>WY</Region> </RowName> <RowName> <CustomerID>THEBI</CustomerID> <City>Portland</City> <Region>OR</Region> </RowName> <RowName> <CustomerID>THECR</CustomerID> <City>Butte</City> <Region>MT</Region> </RowName> <RowName> <CustomerID>TRAIH</CustomerID> <City>Kirkland</City> <Region>WA</Region> </RowName> <RowName> <CustomerID>WHITC</CustomerID> <City>Seattle</City> <Region>WA</Region> </RowName> </DocName>
See Also