Export A2000 in XML format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone tell me if there is a way that I can export data from A2000 in XML
format? Any websites? Forums? Books? Or would it be easier to upgrade myself
to 2002/2003?

Thank you for your time, Ryan
 
Ryan said:
Can anyone tell me if there is a way that I can export data from
A2000 in XML format? Any websites? Forums? Books? Or would it be
easier to upgrade myself to 2002/2003?

Thank you for your time, Ryan

Going from RDMS to XML is actually pretty easy. It's going the other way
that's tough.

The following function will return an XML string provided a Table or Query
name. Al you have to do is write the result to a file using the file i/o
functions in Access/VBA. It creates what I call "Tabular XML" in that each
row of the table is represented with <row> </row> tags and each field is an
attribute. If you want the more traditional "Tag-per-field" format you
should be able to use this as a starting point and make the mods yourself.
For large tables you might need to do the file i/o in-line within this
function so you don't hit the size limit of a String variable.

Function XMLOutput(QryOrTblDef As String, Optional TableName As String) As
String

Dim MyDB As Database
Dim rst As Recordset
Dim fld As Field
Dim strText As String
Dim MyTableName As String

Set MyDB = CurrentDb
Set rst = MyDB.OpenRecordset(QryOrTblDef, dbOpenSnapshot)

strText = "<?xml version=""1.0""?>" & vbCrLf

If IsMissing(TableName) = True Then
MyTableName = QryOrTblDef
Else
MyTableName = TableName
End If

strText = strText & "<" & MyTableName & ">" & vbCrLf
With rst
Do Until .EOF
For Each fld In rst.Fields
strText = strText & " <" & fld.Name & ">" & _
Nz(rst(fld.Name), "NULL_VALUE") & "</" & fld.Name & ">" &
vbCrLf
Next
.MoveNext
Loop
End With

strText = strText & "</" & MyTableName & ">" & vbCrLf

Set rst = Nothing
Set MyDB = Nothing

XMLOutput = strText

End Function
 
Rick,
Thank you for posting this code. Not sure of where I would place/use it
though? Would this be code for a form? I am still green when it comes to the
back end of Access. Thank you for your assistance.
 
i want to figure out on how to export access 2003 tables to XML files with a
basic format like bellow:-
<?xml version="1.0" encoding="UTF-8"?>
<Class>
<student name="Blondie Bush">
<id>1</id>
<height>172 cm</height>
<weight>55 kg</weight>
<hobby>playing guitar</hobby>
<quote>life to the fullest</quote>
<image>images/blondie.jpg</image>
</student>
</Class>

I'm exporting one of the table and the xml output as showing below;-

<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata">
<Class>
<student>
<id>1</id>
<height>172 cm</height>
<weight>55 kg</weight>
<hobby>playing guitar</hobby>
<quote>life to the fullest</quote>
<image>images/blondie.jpg</image>
</student>
</Class>
</dataroot>

as you might notice there is a differences between the two xml files. how to
get rid the <dataroot> and how to make it export the <student name="Blondie
Bush"> format instead of <student>?
my xml structure is strict becource it will be parsed into flash
application. so it would be compulsory to comply with those given xml
structure (i cant change/modify on how flash parsed xml). so the only option
is to make access export into the very similar structure. i dunno much about
access 2003 and am still learning..

Thanks
 
Back
Top