functx:remove-elements

Removes child elements from an XML node, based on name

Description

The functx:remove-elements function removes child elements from the elements in $elements. The $names argument is a sequence of strings that represent child element names to remove. Prefixes can (and must) be used in the $names values for elements that are prefixed in the input documents (using the same prefix). You can also specify wildcard values “*”, “:” and “:” in the second argument. See the description for functx:name-test for details.

The function does not remove all descendants, just children; see functx:remove-elements-deep to remove all descendants with the specified names.

Parameters

Description

elements:element()

the element(s) from which you wish to remove the children

names:string()

the names of the child elements to remove

Examples

XPath

Results

functx:remove-elements($in-xml-1, ‘c’)

<in-xml> <a>123</a> <a>456</a> </in-xml>

functx:remove-elements($in-xml-1, (‘a’,’b’))

<in-xml> <c>Mixed <b>content</b> </c> </in-xml>

functx:remove-elements($in-xml-2, ‘x:a’)

<in-xml> <a>123</a> <c>Mixed <x:a xmlns:x=”http://x”>content</x:a> </c> </in-xml>

Depends On

See Also