xmlUpdate

Updates a part of an XML document (elements, attributes, or nodes) with a new value.

xmlUpdate(node, xpath, value) → returns void

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

Argument Reference

node xml
Required

The XML node in which to update a value

xpath string
Required

XPath expression to locate the XML fragment to update

value string
Required

The new value

Examples
Sample code invoking the xmlUpdate function

Updates the text node of root 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>');
xmlUpdate(xmlData.root, "xmlText", "hello world!");
writeOutput(xmlData.toString());

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

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

Fork me on GitHub