SetAttribute() |
Top Previous Next |
SetAttribute() will create an attribute named <strAttributeName> in the document node <oNode> and give it a value of <strValue>
Example VBScript Code
Private Sub DemoXML()
Dim oXML, ndRoot, ndChild, ndList Dim sBuff, i
'Create the object Set oXML = oUTILITIES.NewCommandoXMLObject()
'Using the With / End With statements make for easy shortcuts With oXML sBuff = "<ROOT></ROOT>" .OpenFromString sBuff Set ndRoot = .GetRootElement() .SetAttribute ndRoot, "DATE", oUTILITIES.VBFormat(Now, "dd mmm yyyy") 'Add Some Child Nodes sBuff = "<CHILD></CHILD>" For i = 1 To 10 Set ndChild = .XMLAddNode(ndRoot, sBuff) .SetAttribute ndChild, "INDEX", i .SetAttribute ndChild, "FIRSTNAME", oUTILITIES.RandomFirstName() Next 'Show the Node List Set ndList = .GetRootChildren() For i = 0 To ndList.Length() - 1 Msgbox "The name is " & .GetAttributeValue(ndList(i), "FIRSTNAME") Next 'Show the XML MsgBox .XML, vbInformation, "The CommandoXML Object" End With 'Clean up the objects Set ndList = Nothing Set ndRoot = Nothing Set ndChild = Nothing Set oXML = Nothing
End Sub
See Also: oUTILITIES.NewCommandoXMLObject() |