This function will load an application resource, pass it into a DOM and return the XML document element.
Private Function GetResourceXMLElement(ByVal varType As Variant, _
ByVal varID As Variant) As MSXML2.IXMLDOMElement
Dim bytResourceData() As Byte
Dim objXML As MSXML2.DOMDocument
' Retrieve the resource contents (data) into a byte array
bytResourceData = LoadResData(varID, varType)
' load into DOM
Set objXML = New MSXML2.DOMDocument
objXML.async = False
' load binary-resource converted into unicode string
If objXML.loadXML(StrConv(bytResourceData, vbUnicode)) Then
Set GetResourceXMLElement = objXML.documentElement
Else
Err.Raise 1, "GetResourceXMLElement", "Bad XML: " & objXML.parseError.reason
End If
End Function
For more general information about how to use XML in Visual Basic 6, take a look at: XML and How To Read It With Visual Basic
2 comments,
Visual Basic 6, Thursday, April 15, 2004 15:32


