XML Persistence Format

Microsoft ActiveX Data Objects (ADO)

ADO 2.5

XML Persistence Format

ADO uses UTF-8 encoding for the XML stream it persists.

The ADO XML format is broken into two sections, a schema section followed by the data section. The following is an example XML file for the Shippers table from the Northwind database. Various parts of the XML are discussed following the example.

<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" 
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" 
xmlns:rs="urn:schemas-microsoft-com:rowset" 
xmlns:z="#RowsetSchema"> 
  <s:Schema id="RowsetSchema"> 
    <s:ElementType name="row" content="eltOnly" rs:updatable="true"> 
      <s:AttributeType name="ShipperID" rs:number="1" 
        rs:basetable="shippers" rs:basecolumn="ShipperID"
        rs:keycolumn="true"> 
        <s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" 
          rs:fixedlength="true" rs:maybenull="false"/> 
      </s:AttributeType> 
      <s:AttributeType name="CompanyName" rs:number="2" 
        rs:nullable="true" rs:write="true" rs:basetable="shippers" 
        rs:basecolumn="CompanyName"> 
        <s:datatype dt:type="string" dt:maxLength="40" /> 
      </s:AttributeType> 
      <s:AttributeType name="Phone" rs:number="3" rs:nullable="true" 
        rs:write="true" rs:basetable="shippers" 
        rs:basecolumn="Phone"> 
        <s:datatype dt:type="string" dt:maxLength="24"/> 
      </s:AttributeType> 
      <s:extends type="rs:rowbase"/> 
    </s:ElementType> 
  </s:Schema> 

  <rs:data> 
    <z:row ShipperID="1" CompanyName="Speedy Express" 
      Phone="(503) 555-9831"/> 
    <z:row ShipperID="2" CompanyName="United Package" 
      Phone="(503) 555-3199"/> 
    <z:row ShipperID="3" CompanyName="Federal Shipping" 
      Phone="(503) 555-9931"/> 
  </rs:data> 
</xml>

The schema shows the declarations of namespaces, the schema section, and the data section. The schema section contains definitions for row, ShipperID, CompanyName, and Phone.

Schema definitions conform to the XML-Data specification and are able to be fully validated (though validation will not occur in Internet Explorer 5). You can view this specification at http://www.w3.org/TR/1998/NOTE-XML-data/. XML-Data is the only supported schema format for Recordset persistence currently.

The data section has three rows containing information about shippers. For an empty rowset, the data section may be empty, but the <rs:data> tags must be present. With no data, you could write the tag shorthand as simply <rs:data/>. Any tag prefixed with "rs" indicates that it is in the namespace defined by urn:schemas-microsoft-com:rowset. The full definition of this schema is defined in the appendix to this document.

© 1998-2003 Microsoft Corporation. All rights reserved.