ElementStatistics - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

XMLTools

 ElementStatistics
 report on the frequency of elements in an XML element

 Calling Sequence ElementStatistics(xmlTree)

Parameters

 xmlTree - Maple XML tree; XML element

Description

 • The ElementStatistics(xmlTree) command returns the frequency of occurrences of each element type that appears in the XML element xmlTree.
 A set of equations is returned indicating the number of each element type name that occurs in the XML element represented by the xmlTree. Each equation has the form $\mathrm{elementName}=\mathrm{elementFrequency}$, where elementName is the name of the element type, and elementFrequency is a non-negative integer that indicates the number of elements of the corresponding type that occur in the element represented by xmlTree.

Examples

 > $\mathrm{with}\left(\mathrm{XMLTools}\right):$
 > $\mathrm{xmlTree}≔\mathrm{XMLElement}\left("a",\left[\right],\mathrm{XMLElement}\left("b",\left[\right],"b text"\right),"some text",\mathrm{XMLElement}\left("b",\left[\right],"more b text"\right)\right):$
 > $\mathrm{ElementStatistics}\left(\mathrm{xmlTree}\right)$
 $\left[{"a"}{=}{1}{,}{"b"}{=}{2}\right]$ (1)

If the XML document was saved in the file named myfile.xml, you could use the following commands to determine the frequency of the elements.

 > $\mathrm{xmlTree}≔\mathrm{CleanXML}\left(\mathrm{ParseFile}\left("myfile.xml"\right)\right):$
 > $\mathrm{ElementStatistics}\left(\mathrm{xmlTree}\right)$