AttributeCount - Maple Help

Home : Support : Online Help : Connectivity : Web Features : XMLTools : XMLTools/Attributes

XMLTools

 Attributes
 return a list of the attributes of an XML element
 AttributeCount
 count the number of attributes in an XML element
 AttributeNames
 retrieve the names of all attributes present in an XML element
 AttributeTable
 construct a table of all attributes present in an XML element

 Calling Sequence Attributes(xmlTree) AttributeCount(xmlTree) AttributeNames(xmlTree) AttributeTable(xmlTree)

Parameters

 xmlTree - Maple XML tree; XML element

Description

 • The Attributes(xmlTree) command returns the attributes of the XML element, xmlTree, as a list of inert functions of _XML_Attribute. The left side of each equation represents the name of the attribute, and the right side represents the attribute's value. The attribute equations in the list appear in the same order that they appear in in the XML element.
 If no attributes are found, an empty list is returned.
 • The AttributeCount(xmlTree) command returns the number of attributes in the XML element xmlTree. This number is always a non-negative integer.
 Attributes of subelements are not included in the count that is returned.
 • The AttributeNames(xmlTree) command returns a list of the names of the attributes present in the XML element xmlTree.
 If no attributes are found, an empty list is returned.
 • The AttributesTable(xmlTree) command takes an XML element tree structure as input and returns a table containing the attributes in the element. The attributes found in an element can be stored in a table and indexed by the attribute name by using this command.

Examples

 > $\mathrm{with}\left(\mathrm{XMLTools}\right):$
 > $\mathrm{xmlTree}≔\mathrm{XMLElement}\left("a",\left["colour"="red","size"="10"\right],\mathrm{XMLElement}\left("b",\left["colour"="blue"\right],"text"\right)\right):$
 > $\mathrm{Print}\left(\mathrm{xmlTree}\right)$
   text
 > $\mathrm{map}\left(\mathrm{Print},\mathrm{Attributes}\left(\mathrm{xmlTree}\right)\right):$
 colour = 'red' size = '10'
 > $\mathrm{AttributeCount}\left(\mathrm{xmlTree}\right)$
 ${2}$ (1)
 > $\mathrm{AttributeNames}\left(\mathrm{xmlTree}\right)$
 $\left[{"colour"}{,}{"size"}\right]$ (2)
 > $\mathrm{AttributeTable}\left(\mathrm{xmlTree}\right)$
 ${table}{}\left(\left[{"colour"}{=}{"red"}{,}{"size"}{=}{"10"}\right]\right)$ (3)
 > $\mathrm{AttributeCount}\left(\mathrm{XMLElement}\left("a"\right)\right)$
 ${0}$ (4)
 > $\mathrm{AttributeCount}\left(\mathrm{XMLElement}\left("a",\left["b"="c"\right]\right)\right)$
 ${1}$ (5)
 > $\mathrm{AttributeCount}\left(\mathrm{XMLElement}\left("a",\left["b"="c"\right],"text"\right)\right)$
 ${1}$ (6)
 > $\mathrm{AttributeCount}\left(\mathrm{XMLElement}\left("a",\left["b"="c","d"="e"\right],"text"\right)\right)$
 ${2}$ (7)
 > $\mathrm{AttributeNames}\left(\mathrm{XMLElement}\left("a"\right)\right)$
 $\left[\right]$ (8)
 > $\mathrm{AttributeNames}\left(\mathrm{XMLElement}\left("a",\left["b"="c","d"="e"\right]\right)\right)$
 $\left[{"b"}{,}{"d"}\right]$ (9)
 > $\mathrm{AttributeNames}\left(\mathrm{XMLElement}\left("a",\left["b"="c","d"="e"\right],\mathrm{XMLText}\left("text"\right)\right)\right)$
 $\left[{"b"}{,}{"d"}\right]$ (10)