GetXMLTagAttributes |
XML | |
Aptilis 2 |
GetXMLTagAttributes(DestinationArray[], PARSED_xml_in_a_string, path)
GetXMLTagAttributes retrieves the attributes of a tag.
As with
GetXMLField
you need to get some XML, parse it with
ParseXML and then indicate a path to
the tag you're interested in.
Warning: Only up to 32 parameters can be retrieved. Any tag containing more
than that will cause an out of memory error.
The path is the form name1:[index].name2[:index]... etc.
If indexes are not specified, then they're assumed to be 0,
so the path will bring back attributes for the first element that it matches.
Indexes start at 0.
Return Value:
A Key based array of name/value pairs for the attributes
of this tag or an empty array if there were no attributes.
In the following example we will load a file called 'test.xml' that contains the
following:
<container technology="tj">
<language quality="super" funpotential="top">Aptilis</language>
</container>
Example:
Simple loading, parsing and field extraction
xml = loadFile("test.xml") $ // We always reset _errno, as loadFile may have set it. _errno = "" $ pxml = parseXML(xml$) $ getXMLTagAttributes(attrs[], pxml$, "CONTAINER.LANGUAGE") for i=0 to getArraySize(attrs[]) - 1 k = getNextKey(attrs[]) $ print("(*) ", k$, ":", attrs[k$]$, "\n") end forResult:
(*) quality:super (*) funpotential:top |
See also parseXML and GetXMLField.