Tim Hastings - NonHostile (because there's no need)

Weblog and collection of geeky articles.

  Home :: Who? :: Contact :: Links :: Subscribe subscribe
Dinner at the SaffronDave's Stag Do in Dublin, March 2006Walk The Dinosaur

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

Timeline Navigation for Visual Basic 6 posts
VB6: Validate XML against XSD in Visual Basic (made 52 minutes later)
VB6: Read XML from a Visual Basic Resource and Return Root Element (this post, made Thursday, April 15, 2004 15:32)
VB6: Free, Easy and Quick Base64 Encoding and Decoding in Visual Basic (made 1 week earlier)


Comments

Post a Comment
Name:  Home page and email address are optional.
  Email addresses will not be displayed or spammed!
Remember these details
Email:
Home Page:
Comment:
Comments cannot contain HTML, URLs will be formatted into hyperlinks.
I reserve the right to remove any comments for any reason.