GetAttributeValue

Top  Previous  Next

Method

GetAttributeValue(oNode, strAttributeName, OPTIONAL strDefaultValue = "")

Parameters

oNode (the DOM node), strAttributeName (String, the name of the attribute), strDefaultValue (String, if the attribute does not exist a default value to return)

Returns

String

 

 

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()