ReplaceChild - Maple Help

XMLTools

 ReplaceChild
 replace a child node of an XML tree

 Calling Sequence ReplaceChild( spec, xmlTree )

Parameters

 spec - equation acceptable to subsop xmlTree - Maple XML tree; XML element

Description

 • The ReplaceChild(spec, xmlTree) command replaces a specific child of an XML document tree with new content.
 • The first argument is an equation whose left-hand side specifies which child to replace, and whose right-hand side is the replacement content. The syntax mimics that of subsop. A new XML document tree is returned with the replacement content appearing instead of the child element specified in the left-hand side of the first argument.

Examples

 > $\mathrm{with}\left(\mathrm{XMLTools}\right):$
 > $\mathrm{doc}≔\mathrm{XMLElement}\left("a",\left[\right],\mathrm{XMLElement}\left("b",\left["colour"="red"\right],"foo"\right),\mathrm{XMLElement}\left("c",\left["colour"="blue"\right],"bar"\right),\mathrm{XMLElement}\left("d",\left[\right],"baz"\right)\right):$
 > $\mathrm{Print}\left(\mathrm{doc}\right)$
   foo   bar   baz
 > $\mathrm{Print}\left(\mathrm{ReplaceChild}\left(2=\mathrm{XMLElement}\left("NEW",\left[\right],"text"\right),\mathrm{doc}\right)\right)$
   foo   text   baz