Home > Language Reference > Classes > XmlParser
Attributes Property
Attributes associated to a tag.
Syntax
Public Property Get Attributes(ByVal iDepth As Integer) As Collection:String
| Parameter | Description |
| iDepth | Zero-based index of the tag on the parser stack. |
Remarks
The Attributes property returns a collection of strings containing the values of the attributes of the specified tag. Calling this property is only meaningful while parsing a document, that is while processing the StartElement, EndElement and CharData events. In any other circumstance, it raises a runtime error.
The iDepth parameter specifies the tag of which attributes are requested. The value 0 refers to the tag at the top of the parser stack, that is the tag being currently analysed; the value 1 refers to the tag one level deeper, that is the tag surrounding the current tag; and so on. Therefore the iDepth parameter must lie between zero and the current height of the XML tree minus one, otherwise a runtime error occurs.
The returned collection contains attribute values indexed by attribute names. The following code displays the pair of name and value for each attributes of each opening tag the parser encounters:
Dim Xml As New XmlParser
Private Sub Xml_StartElement(ByVal sTag As String, ByRef eSpaceMode As HbSpaceMode)
Dim a As Collection:String
Dim i As Integer
a = Xml.Attributes(0)
For i = 1 To a.Count()
MsgBox a.Key(i) & " = " & a.Item(i)
Next i
End SubNote the Attributes property builds a new copy of the collection each time it is called. You can retrieve the name of a tag using the Tag property.
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | N/A |