45 lines
2.0 KiB
Plaintext
45 lines
2.0 KiB
Plaintext
' ------------------------------------------------------------------------
|
|
'XMLPARSER methods
|
|
|
|
'#handle ELEMENTCOUNT() - Return the number of child XML elements
|
|
'#handle KEY$() - Return the key as a string from an XML expression like <key>value</key>
|
|
'#handle VALUE$() - Return the value as a string from an XML expression like <key>value</key>
|
|
'#handle VALUEFORKEY$(keyExpr$) - Return the value for the specified tag key in keyExpr$
|
|
'#handle #ELEMENT(n) - Return the nth child-element XML element
|
|
'#handle #ELEMENT(nameExpr$) - Return the child-element XML element named by nameExpr$
|
|
'#handle ATTRIBCOUNT() - Return a count of attribute pairs; <a attrA="abc" attrB="def"> has two pairs
|
|
'#handle ATTRIBKEY$(n) - Return the key string of the nth attribute
|
|
'#handle ATTRIBVALUE$(n) - Return the value string of the nth attribute
|
|
'#handle ATTRIBVALUE$(n$) - Return the value string of the attribute with the key n$, or an empty string if it doesn't exist.
|
|
'#handle ISNULL() - Returns zero (or false)
|
|
'#handle DEBUG$() - Returns the string "Xmlparser"
|
|
' ------------------------------------------------------------------------
|
|
|
|
' The xml string
|
|
xml$ = "
|
|
<Students>
|
|
<Student Name=""April"" Gender=""F"" DateOfBirth=""1989-01-02"" />
|
|
<Student Name=""Bob"" Gender=""M"" DateOfBirth=""1990-03-04"" />
|
|
<Student Name=""Chad"" Gender=""M"" DateOfBirth=""1991-05-06"" />
|
|
<Student Name=""Dave"" Gender=""M"" DateOfBirth=""1992-07-08"">
|
|
<Pet Type=""dog"" Name=""Rover"" />
|
|
</Student>
|
|
<Student DateOfBirth=""1993-09-10"" Gender=""F"" Name=""Émily"" />
|
|
</Students>"
|
|
|
|
|
|
' Creates the xml handler, using the string
|
|
xmlparser #spies, xml$
|
|
|
|
' Uses elementCount() to know how many elements are in betweeb <spies>...</spies>
|
|
for count = 1 to #spies elementCount()
|
|
|
|
' Uses "count" to work through the elements, and assigns the element to the
|
|
' handle "#spy"
|
|
#spy = #spies #element(count)
|
|
|
|
' Prints the value, or inner text, of "#spy": Sam, Clover, & Alex
|
|
print count;" ";#spy value$();" ->";#spy ATTRIBVALUE$(1)
|
|
|
|
next count
|