真诚请教一个cf修改xml的问题
本人初学,请大家指点!
原xml文件:
<?xml version="1.0" encoding="utf-8"?> <root Name="root"> <child Name="child1" Expression="1000<1>1001<11>/> <child Name="child2" Expression="1000<2>1001<22>/> </root>
<cfset ThisPath="#getDirectoryFromPath(getTemplatePath())#"><cffile action="read" charset="utf-8" file="#ThisPath#1.xml" variable="myXMLFile"><cfset XMLDoc=XMLParse(myXMLFile)><cfset item=XMLDoc.XMLroot.XMLChildren[1]> <form action="edittest.cfm" method="post" > <input name="sExpression" value="<cfoutput>#item.XMLAttributes["Expression"]#</cfoutput>"/> <input type="submit" name="Submit" value="修改" /> </form>
<cfset ThisPath="#getDirectoryFromPath(getTemplatePath())#"><cffile action="read" charset="utf-8" file="#ThisPath#1.xml" variable="myXMLFile"><cfset XMLDoc=XMLParse(myXMLFile)><cfscript>XMLDoc.XMLroot.XMLChildren[1].XMLAttributes["Expression"]= "#form.sExpression#";</cfscript><cffile action="write" addnewline="no" charset="utf-8" file="#1.xml" output="#toString(XMLDoc)#"><cfoutput>成功修改xml文件!</cfoutput>
<cfset form.sExpression = replace(form.sExpression, ">",">","all")>