Using ForXmlTree to map SQL data to hierarchic XML  Example 8

Chapter 2: XML Services

Using OpenXml to map hierarchic XML to SQL

The ForXmlTree function described in “Using ForXmlTree to map SQL data to hierarchic XML” maps a collection of SQL tables or result sets to a hierarchic XML document. The OpenXml function reverses this process, and extracts the data for a SQL table from an input XML document.

OpenXml is similar to the xmlextract function, introduced in Adaptive Server 12.5.1, which extracts a specified data value from a given XML document. xmlextract specifies an XML document and a single XPath query expression. It returns the result of applying the XPath query to the XML document.

The new Java-based OpenXml function:

Thus, you can regard OpenXml as a two-dimensional xmlextract.

OpenXml performs either or both of these actions:

The following examples assume that the XML document in “Sample data and its tree-structured XML representation” is stored in example-document.xml.





Copyright © 2004. Sybase Inc. All rights reserved. Example 8

View this book as PDF