To install it, copy BCXML.dll to the Windows System folder and register it (using regsvr32.exe or other method).
BCXML contains two Class definitions:
Properties & methods
• FileName (String) Sets or returns full path to XML file.
• Root (CXMLElement) Not available until Load is called.
• Load() Loads model from XML file into memory.
You get to the model via the Root property.
• Parse() Does a SAX style parse. You must implement
BeginElement and EndElement event handlers,
but you do not need to implement an interface
like you do with SAX.
• Save([filename]) Writes to disk.
Events
• BeginElement(CXMLElement) Raised when element's open-tag is encountered
• EndElement(CXMLElement) Raised when end-tag or "/>" isa encountered.
Properties & methods
• Name (String) Name of element, from XML tag
• Attributes(AttribName) Sets or returns attribute value.
Assignment will create new attribute if not exists.
• Text (String) Sets or returns XML text.
• Parent (CXMLElement) Returns ref to parent element (Nothing for Root)
• FirstChild() (CXMLElement) Returns Nothing if no children.
• NextChild() (CXMLElement) Returns Nothing if no more children.
• AddChild(CXMLElement)
• Delete Deletes the element (Not yet implemented).
For iterating over all attributes, these are provides:
• AtrributeCount (Integer) The number of attributes.
• AttributeName(i) (String) Returns the i-th attribute name (0 based)
• AttributeValue(i) (String) Returns the i-th attribute value (0 based)
For iterating over all child elements, these are provides:
This is an alternative to using FirstChild and NextChild.
• ChildCount (Integer) The number of attributes.
• Children(i) (CXMLElement) Sets or returns the i-th child element (0 based)
Sub ProcessXML()
Dim doc As CXMLDocument
Set doc = New CXMLDocument
doc.FileName = "c:\mystuff\myxml.xml"
doc.Load
' To process every element...
ProceesOneElement doc.Root
End Sub
Sub ProcessOneEelment(elt As CXMLElement)
Dim e As CXMLElement
' Stuff you want to do with this element goes here...
Debug.Print elt.Name & " " & elt.Attributes("MyAttrib")
Debug.Print elt.Text
' Now process all sub-elements of this element...
Set e = elt.FirstChild
Do Until e Is Nothing
ProcessOneElement e
Set e = elt.NextChild
Loop
End Sub
Sub ProcessXML()
Dim WithEvents doc As CXMLDocument
Set doc = New CXMLDocument
doc.FileName = "c:\mystuff\myxml.xml"
doc.Parse 'Event handlers (below) will be invoked
End Sub
Sub doc_BeginElement(elt As CXMLElement)
Debug.Print elt.Name & " " & elt.Attributes("MyAttrib")
End Sub
Sub doc_EndElement(elt As CXMLElement)
Debug.Print elt.Name & " " & elt.Text
End Sub
Sub ShowAttributes(e As CXMLElement)
Dim i As Integer
For i = 0 To e.AttributeCount - 1
Debug.Print e.AttributeNames(i) & " = " & e.AttributeValues(i)
Next
End Sub
End Sub