|
-
Jul 21st, 2011, 07:23 AM
#1
Thread Starter
Junior Member
[RESOLVED] VB6 and XML pls help
Hi guys i am trying out to following code
to export recordset to XML
//////////////////////////////////////////////////////////////////
Code:
Private Sub cmdMakeXmlFile_Click()
Dim db_name As String
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim xml As DOMDocument
Dim xml2 As DOMDocument
db_name = txtDatabase.Text
Set conn = New ADODB.Connection
conn.ConnectionString = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Persist Security Info=False;" & _
"Data Source=" & db_name
conn.Open
Set rs = conn.Execute("SELECT * FROM Movies ORDER BY Title")
Set xml = New DOMDocument
Set xml2 = New DOMDocument
xml.async = False 'novo
xml2.async = False
rs.Save xml, adPersistXML
rs.Close
conn.Close
db_name = Replace$(db_name, ".mdb", ".xml")
xml.Save db_name
MsgBox "Done"
////////////////////////////////////////////////////////////////////
but i get xml scheme like
<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">
- <s:AttributeType name="Rate" rs:number="1" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="int" dt:maxLength="4" rs recision="10" rs:fixedlength="true" />
</s:AttributeType>
- <s:AttributeType name="RDate" rs:number="2" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="dateTime" rs:dbtype="variantdate" dt:maxLength="16" rs:fixedlength="true" />
</s:AttributeType>
- <s:AttributeType name="Title" rs:number="3" rs:nullable="true" rs:maydefer="true" rs:writeunknown="true">
<s:datatype dt:type="string" dt:maxLength="40" />
</s:AttributeType>
<s:extends type="rs:rowbase" />
</s:ElementType>
</s:Schema>
- <rs:data>
<z:row Rate="2" RDate="2010-05-01T00:00:00" Title="Adam2" />
<z:row Rate="3" RDate="2010-05-01T00:00:00" Title="Adam3" />
<z:row Rate="4" RDate="2010-05-01T00:00:00" Title="Adam4" />
<z:row Rate="1" RDate="2010-05-01T00:00:00" Title="Adm" />
<z:row Rate="5" RDate="2010-05-01T00:00:00" Title="Eva" />
</rs:data>
</xml>
////////////////////////////////////////////////////////////////////
But i need a simple tree like
<?xml version="1.0" encoding="utf-8" ?>
- <Movies xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MovieName>sws</MovieName>
<MovieRating>2011-07-30T00:00:00+03:00</MovieRating>
<MovieReleaseDate>223467</MovieReleaseDate>
</Movies>
/////////////////////////////////////////////////////////////////////
Any ideas?!
-
Jul 21st, 2011, 11:28 AM
#2
Re: VB6 and XML pls help
Simple serialization of an ADO Recordset to XML uses special schemas as you have seen.
To do anything else you have to perform the serialization manually. This is no big deal until you want to use your own (or the stock) schemas. For example nodes of type xsd:dateTime have to be encoded as ISO 8601 date & time strings, and VB6 has no readily available support for doing this (roll your own code).
I'm not even sure what type this element is supposed to be:
<MovieReleaseDate>223467</MovieReleaseDate>
By rights I'd expect xsd:date, but those look like:
2002-09-24
2002-09-24Z
2002-09-24+06:00
etc.
-
Jul 21st, 2011, 11:37 AM
#3
Re: VB6 and XML pls help
and if you look at the OP's rating node, it's a date... I think it's a simple swap/mistype ...
-tg
-
Jul 21st, 2011, 12:09 PM
#4
Re: VB6 and XML pls help
Duhhh! (smacks forehead)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|