[
Lists Home |
Date Index |
Thread Index
]
Title: Binary Encoding using Base64
Good morning all,
I have been trying to encode a gif file as xml using base64. I am using the MSXML4 parser and although I have had no trouble encoding and decoding text strings, I have had no luck at all when trying to work with gifs.
The code I am using is as follows
Public Function ConvertToBase64() As MSXML2.IXMLDOMElement
Dim oDOM As MSXML2.FreeThreadedDOMDocument40
Dim oElement As MSXML2.IXMLDOMElement
Dim btArr() As Byte
Dim oNode As MSXML2.IXMLDOMNode
Set oDOM = New MSXML2.FreeThreadedDOMDocument40
Set oElement = oDOM.createElement("BINARY")
oDOM.appendChild oElement
oElement.dataType = "bin.base64"
'Open the gif file
Open "C:\i2_logo.gif" For Binary As #1
Get #1, 1, btArr
Close #1
'Assign the data to the Binary node
Set oNode = oDOM.selectSingleNode("BINARY")
oNode.nodeTypedValue = btArr <The error occurs here - The parameter is incorrect>
'Append the element
oElement.appendChild (oNode)
'Save the XML
oDOM.save "C:\test.xml"
Set oElement = Nothing
Set oDOM = Nothing
End Function
I must be missing something fundamental but I just don't see it.......
Thanks
Jason
Jason Brown
I2 Limited
The Visual Space
Capital Park
Fubourn
Cambridge
CB1 5XH
Tel: (01223) 728 670
Fax: (01223) 728 601
Mobile: 07952 246 375
|