Creating the C++ OCI Helper Class
To use the XML APIs from C++, you must create a compatible context. In the case of a midtier or client application, you do this with the built-in xmlinit() method in the XMLParser class. However, in the case of working with the database, you need to call a method to initialize the OCI context along with the XML context. At the same time, you need to establish a database connection and submit your query in order to return the DOM of the XMLType you are interested in. You do all of this with the ociapi class specified in the previous header file, which has the following member functions:init_env_handle() Creates and initializes and the OCI environment
connect_server() Creates a database connection and passes in the user ID and password
disconnect_server() Disconnects from the server, ending the session
cleanup() Cleans up the OCI environment
select_and_query() Submits the SQL/XML statement and returns the DOM of the
XMLType result while calling out to the DOM APIs to do the XPath query
query_xmlApi() Performs C++ XPath operations on XMLType and prints the result
The following sections examine the actual source code for the ociapi class implementation, broken down by its member functions.