NewCommandoXMLObject

Top  Previous  Next

Method

NewCommandoXMLObject()

Parameters

None

Returns

Object (A CommandoXML Object)

Example

see below;  See Also CommandoXML

 

Private Sub ShowSampleXML() 

Dim oXML, ndRoot, ndChild

Dim sBuff

With oUTILITIES

  Set oXML = .NewCommandoXMLObject()

End With

 

With oXML

   'Create a simple XML document    

   sBuff = "<ROOT></ROOT>"

   .OpenFromString sBuff

   Set ndRoot = .GetRootElement()

   'Set some attributes 

   .SetAttribute ndRoot, "MYID", "12345"

   .SetAttribute ndRoot, "MYFIRSTNAME", "John"

   .SetAttribute ndRoot, "MYLASTNAME", "Dough"

   .SetAttribute ndRoot, "CHILDREN", 3

   'You can also use the GetAttributeValue() method

    sBuff = .GetAttributeValue(ndRoot,"CHILDREN")

    MsgBox "I have " & sBuff & " children", VBINFORMATION, ".GetAttributeValue() Method"

    'Now add some child nodes

   sBuff = "<CHILD></CHILD>"

   Set ndChild = .XMLAddNode(ndRoot, sBuff)

   .SetAttribute ndChild, "NAME", "Joe"

   .SetAttribute ndChild, "AGE", 5

   Set ndChild = .XMLAddNode(ndRoot, sBuff)

   .SetAttribute ndChild, "NAME", "Mary"

   .SetAttribute ndChild, "AGE", 4

   Set ndChild = .XMLAddNode(ndRoot, sBuff)

   .SetAttribute ndChild, "NAME", "Huey"

   .SetAttribute ndChild, "AGE", 1

   'ndChild is actually just a MS DOM Node object, you can access it's properties directly

    ndChild.Text = "Huey is just 1 year old" 

 

MsgBox .XML, VBINFORMATION, "Sample XML"

End With 

Set oXML = Nothing

End Sub