I used your code snippet like this:

<cfobject action="create" class="MSXML2.DOMDocument" name="xmldoc">
<cfset xml = "<mother><daughter>This is a test</daughter></mother>">
<cfscript>
xmldoc.loadXML('#xml#');
root = xmldoc.documentElement;
todelete=xmldoc.selectSingleNode("mother/daughter");
deleteSuccess = root.removeChild(todelete);
</cfscript>

And it worked perfectly. But then I tried it like this:

<cfobject action="create" class="MSXML2.DOMDocument" name="xmldoc">
<cfset xml = "<mother><firstdaughter>This is a 
test</firstdaughter><seconddaughter><baby>Test</baby></seconddaughter></mother>">
<cfscript>
xmldoc.loadXML('#xml#');
root = xmldoc.documentElement;
todelete=xmldoc.selectSingleNode("mother/seconddaughter/baby");
deleteSuccess = root.removeChild(todelete);
</cfscript>

And here I got the "Unknown Exception" error. Note that I'm deleting a node that is on 
the third level of the tree.
Anybody got any ideas?

Rafi

----Original Message-----

Hi Rafael

The removeChild method of an MSXML object certainly works in ColdFusion -
here's an example of it in action in our XML content management system:

<cfobject action="create" class="MSXML2.DOMDocument" name="xmldoc">
<cfscript>
xmldoc.loadXML('#form.xml#');
root = xmldoc.documentElement;
todelete=xmldoc.selectSingleNode("article_xml/object[@id='#form.id#']");
deleteSuccess = root.removeChild(todelete);
</cfscript>

I'm confident that the insertbefore and replacechild methods will work too -
the only known problems with ColdFusion and MSXML appear when using CF5 and
the XSLStylesheet interface. Unfortunately MSXML doesn't return any useful
error messages to CFOBJECT (unlike other COM objects) so it's very difficult
to know what's going wrong.

If the little code snippet above doesn't help, perhaps you could show us
your code?

Tom



-----------------------+
cf-xml mailing list
list: [EMAIL PROTECTED]
admin: [EMAIL PROTECTED]
home: http://torchbox.com/xml

Reply via email to