SAMPLE: How to Retrieve Hierarchical Recordsets from XML Data Using MSDAOSP with ADO in Visual C++ (271778)



The information in this article applies to:

  • Microsoft Data Access Components 2.6
  • ActiveX Data Objects (ADO) 2.6
  • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
  • Microsoft Visual C++, 32-bit Professional Edition 6.0
  • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q271778

SUMMARY

The Ospxml.exe sample demonstrates how to retrieve hierarchical ActiveX Data Objects (ADO) recordsets from an arbitrary XML document using the Microsoft OLE DB Simple Provider (MSDAOSP) that ships with Microsoft Data Access Components (MDAC) version 2.6.

MORE INFORMATION

The following file is available for download from the Microsoft Download Center:
Release Date: Oct-17-2000

For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file. The Ospxml.exe file contains the following files:

File nameSize
EULA.txt2 KB
Ospxml.cpp6 KB
Portfolio.xml1 KB
The OSP Provider that ships with MDAC 2.6 has been enhanced to support opening hierarchical ADO recordsets over arbitrary XML files. The OSP Provider supports the following four different naming conventions for specifying the path to the file:
  • http://
  • file://
  • UNC path
  • Full DOS path

Limitations

  • Client cursors (adUseClient) are not supported.

  • Hierarchical recordsets cannot be persisted using the Save method of the Recordset object.

  • Recordsets created with the MSDAOSP are read-only.

  • The XMLDSO (MSXML2.DSOControl.2.6) adds an additional column of Data ($Text) to each recordset in the hierarchy.
The Ospxml.exe sample loads an arbitrary XML document named Portfolio.xml into the OSP Provider and outputs the hierarchical recordset retrieved from it. Additionally, the sample illustrates how to traverse the parent-child hierarchy recursively and ignore the $Text field while outputting the data.

Steps to Run the Sample

  1. Create an empty Win32 console application.
  2. Insert Ospxml.cpp into the project.
  3. Copy Portfolio.xml into the project folder.
  4. Compile and then run the application.

REFERENCES

For additional information about XML Data And ADO/VC++ samples, click the article numbers below to view the articles in the Microsoft Knowledge Base:

272177 SAMPLE: How to Retrieve XML Data in VC++ Using an XPATH Query

272185 SAMPLE: How to Retrieve Data Using a SQL XML Query in ATL OLE DB

271782 SAMPLE: How To Retrieve XML Data Using an XPATH query with ADO in Visual C++

271775 SAMPLE: HowTo Retrieve Relational Data Using OpenXML with ADO in Visual C++

272180 SAMPLE: How to Retrieve XML Data Using a Template File with ADO in Visual C++


Modification Type:MinorLast Reviewed:8/5/2004
Keywords:kbdownload kbfile kbinfo kbMSXMLnosweep KB271778 kbAudDeveloper