XmlUpdate

Description

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

Returns

None

Category

XML functions

Syntax

XmlUpdate(node,xpath,value)
XmlUpdate(node,xpath,value)
XmlUpdate(node,xpath,value)

Parameters

Parameter Description
node The XML node where you must update a value.
xpath XPath expression to locate the XML fragment to update.
value The new value.

Example

<cfxml variable="xmlData">
<root>
<item id="1">Item 1</item>
<item id="2">Item 2</item>
<item id="3">Item 3</item>
hello
</root>
</cfxml>
<cfscript>
writeDump(xmlData)
writeOutput("<br/>")
xmlUpdate(xmlData.root,"xmlText","hello again!")
writeDump(xmlData)
</cfscript>
<cfxml variable="xmlData"> <root> <item id="1">Item 1</item> <item id="2">Item 2</item> <item id="3">Item 3</item> hello </root> </cfxml> <cfscript> writeDump(xmlData) writeOutput("<br/>") xmlUpdate(xmlData.root,"xmlText","hello again!") writeDump(xmlData) </cfscript>
<cfxml variable="xmlData">
  <root>
    <item id="1">Item 1</item>
    <item id="2">Item 2</item>
    <item id="3">Item 3</item>
	hello
  </root>
</cfxml>
<cfscript>
    writeDump(xmlData)
    writeOutput("<br/>")
    xmlUpdate(xmlData.root,"xmlText","hello again!")
    writeDump(xmlData)
</cfscript>

Try in CFFiddle

Получете помощ по-бързо и по-лесно

Нов потребител?