StripAttributes - Maple Help

XMLTools

 StripAttributes
 remove all attributes from an XML element
 remove all comments from an XML element

Parameters

 xmlTree - Maple XML tree; XML element

Description

 • The StripAttributes(xmlTree) command removes all attributes from the XML element xmlTree and returns the resulting XML tree.
 • The StripComments(xmlTree) command removes all comment structures from the XML element xmlTree and returns the resulting XML tree.
 If the input XML tree xmlTree does not have any comments, then the tree is simply returned.
 Note: When using these functions, attributes and/or comments are removed at all levels (or subelements) of the XML data structure xmlTree, not only the top-level element that it represents. The resulting XML data structure is completely free of attributes and/or _XML_COMMENT calls.

Examples

 > $\mathrm{with}\left(\mathrm{XMLTools}\right):$
 > $\mathrm{xmlTree1}≔\mathrm{XMLElement}\left("a",\left["colour"="red"\right],\left["some text",\mathrm{XMLElement}\left("b",\left["colour"="blue"\right],"more text"\right)\right]\right)$
 ${\mathrm{xmlTree1}}{≔}{\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"a"}\right){,}\left[{\mathrm{_XML_Attribute}}{}\left({\mathrm{_XML_AttrName}}{}\left({"colour"}\right){,}{\mathrm{_XML_AttrValue}}{}\left({"red"}\right)\right)\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"some text"}\right){,}{\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"b"}\right){,}\left[{\mathrm{_XML_Attribute}}{}\left({\mathrm{_XML_AttrName}}{}\left({"colour"}\right){,}{\mathrm{_XML_AttrValue}}{}\left({"blue"}\right)\right)\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"more text"}\right)\right]\right)\right]\right)$ (1)
 > $\mathrm{StripAttributes}\left(\mathrm{xmlTree1}\right)$
 ${\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"a"}\right){,}\left[\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"some text"}\right){,}{\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"b"}\right){,}\left[\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"more text"}\right)\right]\right)\right]\right)$ (2)
 > $\mathrm{xmlTree2}≔\mathrm{XMLElement}\left("a",\left["colour"="red"\right],\left["some text",\mathrm{XMLElement}\left("b",\left[\right],\mathrm{XMLComment}\left("a comment"\right),"more text"\right)\right]\right)$
 ${\mathrm{xmlTree2}}{≔}{\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"a"}\right){,}\left[{\mathrm{_XML_Attribute}}{}\left({\mathrm{_XML_AttrName}}{}\left({"colour"}\right){,}{\mathrm{_XML_AttrValue}}{}\left({"red"}\right)\right)\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"some text"}\right){,}{\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"b"}\right){,}\left[\right]{,}\left[{\mathrm{_XML_Comment}}{}\left({"a comment"}\right){,}{\mathrm{_XML_Text}}{}\left({"more text"}\right)\right]\right)\right]\right)$ (3)
 > $\mathrm{StripComments}\left(\mathrm{xmlTree2}\right)$
 ${\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"a"}\right){,}\left[{\mathrm{_XML_Attribute}}{}\left({\mathrm{_XML_AttrName}}{}\left({"colour"}\right){,}{\mathrm{_XML_AttrValue}}{}\left({"red"}\right)\right)\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"some text"}\right){,}{\mathrm{_XML_Element}}{}\left({\mathrm{_XML_ElementType}}{}\left({"b"}\right){,}\left[\right]{,}\left[{\mathrm{_XML_Text}}{}\left({"more text"}\right)\right]\right)\right]\right)$ (4)