I have the following xml file (excerpt):
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="blog.xsl"?> <demoChanges> <entry ID="12345"> <heading>test</heading> <descr>test</descr> <author>Mark</author> <date>April 22, 2014</date> <cert>Mark</cert> <draft>no</draft> </entry> </demoChanges>
I am able to read the xml file, parse it, then using XmlSearch I am able to locate the entry node with the id of "12345", which is a value passed in via a form field (#form.threadid#).
<cffile action="read" file="/path/to/my/xml/file/blog.xml" variable="xmlFile"> <cfset myXml = XmlParse(xmlFile)> <cfset myNode = XmlSearch(myXml, "/demoChanges/entry[@ID=#threadid#]") />
What I would like to do now is add a child element called "comment" to this node only, and populate it with a form field value (#formThreadDescr#). I have tried several ways but to no success. Here is but one that has failed me:
<cfset myXml.myNode.comment = XmlElemNew(myXml, "comment")> <cfset myXml.myNode.comment.xmltext = #formThreadDescr#>
I have tried several others with various resulting errors. Not sure how to do this. Any help will be greatly appreciated as always.
This post has been edited by midasxl: 23 April 2014 - 06:09 AM