sarcus25
Programmer
- Apr 14, 2005
- 27
Hi I'm Kind of new to cold Fusion, at the moment I'm trying to overwrite to an existing element in a Xml File. I can retrieve and view the element of my choice but I'm not sure how to Modify that element then write it back into the XML Ducument Object.
For Instance:
<!--- Convert file to XML document object --->
<cffile action="read" file="C:\CFusionMX7\ variable="myxml" charset="utf-8">
<cfset mydoc = XmlParse(myxml)>
<!---Extract INvoice number--->
<cfset InvoiceNum=#mydoc.ExternalOrder.Workstation#>
<!---Not sure how to write the "modified value" along with the rest of the elements into the file in the same order. For example if the user changes InvoiceNum to 4 then how do I put this value back into the "mydoc" XML object --->
<!---Converting the XML object back into string then save to a file--->
<cfset Xmltext = tostring(mydoc)>
<cffile action="write" file="C:\CFusionMX7\ output="#Xmltext#">
For Instance:
<!--- Convert file to XML document object --->
<cffile action="read" file="C:\CFusionMX7\ variable="myxml" charset="utf-8">
<cfset mydoc = XmlParse(myxml)>
<!---Extract INvoice number--->
<cfset InvoiceNum=#mydoc.ExternalOrder.Workstation#>
<!---Not sure how to write the "modified value" along with the rest of the elements into the file in the same order. For example if the user changes InvoiceNum to 4 then how do I put this value back into the "mydoc" XML object --->
<!---Converting the XML object back into string then save to a file--->
<cfset Xmltext = tostring(mydoc)>
<cffile action="write" file="C:\CFusionMX7\ output="#Xmltext#">