Removes a node from an XML document by specifying the position

xmlDeleteAt(xmlObject, position) → returns void

This function requires Adobe ColdFusion 2023 and up.  Not supported on Lucee, etc.

Argument Reference

xmlObject xml

The XML object

position numeric

The position of the child node to be deleted

Sample code invoking the xmlDeleteAt function

Deletes a single node in a simple XML document

xmlData = xmlParse('<root><item id="1">Item 1</item><item id="2">Item 2</item><item id="3">Item 3</item></root>');
xmlDeleteAt(xmlData.root.item, 1);

Expected Result: <?xml version="1.0" encoding="UTF-8"?> <root><item id="2">Item 2</item><item/><item id="3">Item 3</item></root>

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub