The process of retrieving XML data from a database using the ArcSDE API is
similar to retrieving layers or raster datasets.
To retrieve XML data, an XML document object is created and used as a
placeholder for the object returned by the SeRow.getXML() Java API method or the
SE_stream_get_xml() C API function. For advanced queries involving XPath search constraints, the application must formulate a query string that follows a subset of the XPath standard.
The following code snippets demonstrate how XML data is retrieved using the C
and Java APIs. It is assumed here that an XML document has already been inserted into the database. For more on inserting data, see the Data
Loading section.
LONG rc;
SHORT col_no;
CHAR *columns[2], by_clause[128];
SE_XMLCOLUMNINFO xmlcolumn;
rc = SE_queryinfo_set_tables (qinfo, 1, &table, NULL);
columns[0] = XMLCOL;
col_no = 0;
rc = SE_queryinfo_set_columns (qinfo, col_no + 1, columns);
rc = SE_stream_query_with_info (stream, qinfo);
rc = SE_stream_execute (stream);
rc = SE_stream_free (stream);
SE_queryinfo_free (qinfo);
SeConnection conn = ...
SeTable table = ....;
SeQuery query = new SeQuery(conn);
SeSqlConstruct sql = new SeSqlConstruct(table.getQualifiedName(), null);
SeQueryInfo qInfo = new SeQueryInfo();
qInfo.setConstruct(sql);
qInfo.setColumns(columns);
query.prepareQueryInfo(qInfo);
query.execute();
|
LONG rc, keyval, key_index;
SHORT keyind, xmlind, col_no;
CHAR xml_text[1024];
SE_XMLDOC xmldoc;
*rows = 0;
rc = SE_xmldoc_create (&xmldoc);
col_no = 1;
rc = SE_stream_bind_output_column (stream, ++col_no, xmldoc, &xmlind);
rc = SE_stream_fetch (stream);
rc = SE_xmldoc_get_text (xmldoc, xml_text);
SE_xmldoc_free (xmldoc);
SeXmlDoc xmlDoc = new SeXmlDoc();
String document = null;
SeRow row = query.fetch();
xmlDoc = row.getXml(column_num);
document = xmlDoc.getText();
query.close();
|
See also
|