ADO XML conversion

Since ActiveX Data Objects version 2.1 (ADO 2.1) or later, Microsoft ADO engine could provide the XML file as a Microsoft XML - Data Schema format, also known as XMLData Reduced Schema, or simply Reduced Data. XML Data Reduced Schemadatatypes and stating the similar nature of the schema (ie, default values, informationabout the primary key. etc.) from the database and to this news in the first part of theXML file. The following section contains data in XML format of the rows.

Once I have the ADO recordset and then, you can store (save) data in an XML file by using the FunctionSave the recordset. ADO 2.1 tells us the save data into an XML file. But it ADO 2.5 recordset convert intostreaming format. If the first argument of the function is a URL, then Save to save the data in the form ofintrinsic binary format . However, if we add the second argument is adPersistXML flag shall be converted into an XML stream to stream.

If you've never heard the name from the stream before, imagine this conversation. There are two ways to dealer delivery watermelon. The first way they carried watermelons from the boat to shore, piled in a small mountain on the floor for a while after you found the person to carry away. Second, you found the pair drove to the scene on the river, a boat dealer stand under each watermelon throwing up for a car you stand on every shot and then passed on to other people about this car or other vehicle if seen through to classify large and small watermelon.
The first delivery location like save data to a file. In a Monday delivery, the melon fruit fly is constantly throwing up banks of the water like a shot away, the literal meaning of the text stream is a stream of water.
When data is transmitted as a stream, the receiver can process data immediately, and sometimes no longer contain data. In this example, has taken a coconut seller must decide immediately if the big watermelon for this car, if small watermelon or slightly exceed the total of the other vehicle.
In ADO 2.1, you are forced to a file output stream, which as a waste of time. The stream must be converted into Unicode formated text string, through the spool file to hard disk interface. Then if you need the XML file that must be loaded and parsed back into XML stream. ADO 2.5 lets you write directly results in an XMLDOM (Document Object Model) document, out to save the file and read and parse again.

Sample program

You can download sample programs ADOXML.zip to see how to save data from ADO XML. Bonus is the load data from XML and save back into the Access Database. To run the program you need ADOXML Project | References two libraries: Microsoft ActiveX Data Objects 2.5 Library and Microsoft Data Binding Collection.

ADO recordset used here to represent data from the Publishers table BIBLIO.MDB database. The result is an XML file consists of three parts:

Part One: data introduced in the form of XML attributes



xml xmlns: s = "uuid: BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns: dt = "uuid: C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns: RS = "ÜRN: schemas-microsoft-com: rowset "xmlns: v =" # RowsetSchema " >

Part Two: Schema, cut definition of the datatype and data structure



s: Schema id = "RowsetSchema" >
<s:ElementType name="row" content="eltOnly" rs:updatable="true">
<s:AttributeType name="PubID" rs:number="1" rs:maydefer="true" rs:basetable="Publishers" rs:basecolumn="PubID" rs:keycolumn="true">
<s:datatype dt:type="int" dt:maxLength="4" rs:precision="10" rs:fixedlength="true"></s:datatype>
</s:AttributeType>
<s:AttributeType name="Name" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:write="true" rs:basetable="Publishers" rs:basecolumn="Name">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="50"></s:datatype>
</s:AttributeType>
<s:AttributeType name="c2" rs:name="Company Name" rs:number="3" rs:nullable="true" rs:maydefer="true" rs:write="true" rs:basetable="Publishers" rs:basecolumn="Company Name">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="255"></s:datatype>
</s:AttributeType>
<s:AttributeType name="Address" rs:number="4" rs:nullable="true" rs:maydefer="true" rs:write="true" rs:basetable="Publishers" rs:basecolumn="Address">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="50"></s:datatype>
</s:AttributeType>
<s:AttributeType name="City" rs:number="5" rs:nullable="true" rs:maydefer="true" rs:write="true" rs:basetable="Publishers" rs:basecolumn="City">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="20"></s:datatype>
</s:AttributeType>
<s:AttributeType name="Fax" rs:number="6" rs:nullable="true" rs:maydefer="true" rs:write="true" rs:basetable="Publishers" rs:basecolumn="Fax">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="15"></s:datatype>
</s:AttributeType>
<s:AttributeType name="State" rs:number="7" rs:nullable="true" rs:maydefer="true" rs:write="true" rs:basetable="Publishers" rs:basecolumn="State">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="10"></s:datatype>
</s:AttributeType>
<s:AttributeType name="Telephone" rs:number="8" rs:nullable="true" rs:maydefer="true" rs:write="true" rs:basetable="Publishers" rs:basecolumn="Telephone">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="15"></s:datatype>
</s:AttributeType>
<s:AttributeType name="Zip" rs:number="9" rs:nullable="true" rs:maydefer="true" rs:write="true" rs:basetable="Publishers" rs:basecolumn="Zip">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="15"></s:datatype>
</s:AttributeType>
<s:AttributeType name="Comments" rs:number="10" rs:nullable="true" rs:maydefer="true" rs:write="true" rs:basetable="Publishers" rs:basecolumn="Comments">
<s:datatype dt:type="string" rs:dbtype="str" dt:maxLength="1073741824" rs:long="true"></s:datatype>
</s:AttributeType>
s extends type = "rs: rowbase" </ s: extends >
</ s: element type >
</ s: Schema >

Part three: data, each datafield value is an attribute value of row



<rs:data>
z: row PubID = "1" Name = "SAMS" c2 = "SAMS" Address = "11711 N. College Ave, Ste 140" City = "Caramel" Fax = "" State = "IN" Telephone = "" Zip = "46032" Comments = "" </ z: row >
z: row PubID = "2" Name = "Prentice Hall" c2 = "Prentice Hall" Address = "15 Columbus Cir. City = "New York" Fax = "" State = "NY" Telephone = "800-922-0579" Zip = "10023" Comments = "" </ z: row>
<z:row PubID="3" Name="M & T" c2="M & T BOOKS" Address=" " City=" " Fax=" " State=" " Telephone=" " Zip=" " Comments=" "></z:row>
<z:row PubID="4" Name="MIT" c2="MIT PR" Address="Long Island" City=" " Fax=" " State="N.Y." Telephone=" " Zip=" " Comments=" "></z:row>
z: row PubID = "5" Name = "MACMILLAN COMPUTER" c2 = "MACMILLAN COMPUTER PUB" Address = "11 W. 42nd St., 3rd flr. City = "New York" Fax = "" State = "NY" Telephone = "212-869-7440" Zip = "10036" Comments = "" </ z: row >
<z:row PubID="6" Name="HIGHTEXT PUBNS" c2="HIGHTEXT PUBNS" Address=" " City=" " Fax=" " State=" " Telephone=" " Zip=" " Comments=" "></z:row>
z: row PubID = "7" Name = "SPRINGER Verlag" c2 = "SPRINGER Verlag" Address = "" City = "" Fax = "" State = "" Telephone = "" Zip = "" Comments = "" </ z: row >
<z:row PubID="8" Name="O" REILLY=" c2=" O'REILLY=" Address=" 90="
City = 'Cambridge' = "State =" MA "Telephone =" "Zip =" 02140 "Comments =" " 
</ z: row >
z: row PubID = "9" Name = "ADDISON-WESLEY" c2 = "ADDISON-WESLEY PUB CO" Address = "Rte 128" City = "Reading" Fax = "617-964-9460" State = "MA" telephone = "617-944-3700" Zip = "01867" Comments = "" </ z: row >
<z:row PubID="10" Name="JOHN WILEY & SONS" c2="JOHN WILEY & SONS" Address="605 Third Ave" City="New York" Fax="212-850-6088 " State="NY" Telephone="212-850-6000" Zip="10158" Comments="DATABASES MICROCOMPUTER SOFTWARE PAPERBACK BOOKS - TRADE TEXTBOOKS - COLLEGE DICTIONARIES, ENCYCLOPEDIAS PERIODICALS
PROFESSIONAL BOOKS
SCIENCE (GENERAL)
BUSINESS
SOCIAL SCIENCES AND SOCIOLOGY
COMPUTER SCIENCE, DATA PROCESSING
ENGINEERING (GENERAL) " 
</ z: row >
<z:row PubID="11" Name="SINGULAR" c2="SINGULAR PUB GROUP" Address=" " City=" " Fax=" " State=" " Telephone=" " Zip=" " Comments=" "></z:row>
z: row PubID = "12" Name = "Duke Press" c2 = "Duke Press" Address = "" City = "" Fax = "" State = "" Telephone = "" Zip = "" Comments = "" </ z: row >
z: row PubID = "13" Name = "Oxford University" c2 = "Oxford University Press Address =" "City =" "Fax =" "State =" "Telephone =" "Zip =" "Comments =" " </ z: row >
z: row PubID = "14" Name = "MIT Press" c2 = "MIT Press" Address = "" City = "" Fax = "" State = "" Telephone = "" Zip = "" Comments = "" </ z: row >
z: row PubID = "15" Name = "CAMBRIDGE UNIV" c2 = "CAMBRIDGE UNIV PR" Address = "" City = "" Fax = "" State = "" Telephone = "" Zip = "" Comments = "" </ z: row >
z: row PubID = "16" Name = "QE D" C2 = "QED PUB CO" Address = "" City = "" Fax = "" State = "" Telephone = "" Zip = "" Comments = "" </ z: row >
z: row PubID = "17" Name = "Cambridge University" c2 = "Cambridge University Press" Address = "" City = "" Fax = "" State = "" Telephone = "" Zip = "" Comments = "" </ z: row >
z: row PubID = "18" Name = "World Scientific" c2 = "WORLD SCIENTIFIC PUB CO" Address = "" City = "" Fax = "" State = "" Telephone = "" Zip = "" Comments = " " </ z: row >
<z:row PubID="19" Name="IDG" c2="IDG BOOKS WORLDWIDE" Address=" " City=" " Fax=" " State=" " Telephone=" " Zip=" " Comments=" "></z:row>
<z:row PubID="20" Name="GOWER PUB" c2="GOWER PUB CO" Address=" " City=" " Fax=" " State=" " Telephone=" " Zip=" " Comments=" "></z:row>
</rs:data>
</xml>

0 comments:

Post a Comment