Blog

15Jun
2005
Can't Directly Add An XML DOM To An XML Dom

A ColdFusion user e-mailed me with a problem; he needed to add an XML DOM into another XML DOM, essentially making the first DOM a child node of the first one. Simple assignments returned the following error:

WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.

The problem is that ColdFusion will not allow a DOM to be directly assigned to another DOM. The solution is to simply add the desired nodes and elements one by one using the XMLElemNew() function.

Comments (5)



  • Ralph Ogden

    I can't seem to do this without overwriting all the child elements completely.

    I.E. How do you join this xml:

    <shoppingList>
       <fruits>
          <apples>5</apples>
          <bananas>5</bananas>
       </fruits>
    </shoppingList>

    with this xml:

    <vegetables>
       <carrots>5</carrots>
    </vegetables>

    to get this xml:

    <shoppingList>
       <fruits>
          <apples>5</apples>
          <bananas>5</bananas>
       </fruits>
       <vegetables>
          <carrots>5</carrots>
       </vegetables>
    </shoppingList>

    #1Posted by Ralph Ogden | Dec 21, 2005, 03:46 PM
  • Joe

    This worked really well for me:

    http://www.bennadel.com/blog/701-Copying-Children-...

    #2Posted by Joe | Oct 8, 2007, 02:32 PM
  • estetik

    AJAX does have its own category. As there <a href="http://www.nakliyatankara.com " title="ankara nakliyat">ankara nakliyat</a> are many AJAX frameworks (dojo, YUI, prototype, jQuery, Ext JS, etc). We simply <a href="http://www.uluslararasi-nakliyat.org " title="ankara nakliyat">ankara nakliyat</a> chose to include AJAX as a single choice. Perhaps a future poll can drill into individual AJAX framework preferences among developers.

    2
    Note when editing MMDocumentTypes.xml - the first extension in <a href="http://www.lazerepilasyonn.org " title="lazer epilasyon">lazer epilasyon</a> the list seems to be the default DW uses when saving a new file of a particular type (so if you add a weird extension, you might <a href="http://www.estetik-merkezleri.com"; title="burun esteti?i">burun esteti?i</a> want to add it at the end of the list). Also note that file has separate extension lists for Windows and Mac.
    3
    Hi all
    All I want a book that opens with the /apology/ "Actionscript 3.0 is kinda <a href="http://www.sacekimii.com " title="saç ekimi">saç ekimi</a> retarded. It's in transition from being a light scripting language to a robust object-oriented <a href="http://www.lidarehberi.com " title="lida">lida</a> language, and 3.0 is a silly little in-between step that requires you to explicitly declare every variable, but doesn't require terminating semi-colons on lines."
    4
    Clickjacking has been fixed now already. People <a href="http://www.ankaraevdeneve.biz " title="ankara evden eve">ankara evden eve</a> using it for the old copy clipboard function (which Flash 10 broke) should <a href="http://www.nakliyatankara.com " title="evden eve nakliyat">evden eve nakliyat</a> look for other solutions. I saw a good example here:

    #3Posted by estetik | Jan 9, 2009, 04:47 AM
  • tabldot yemek

    A ColdFusion user e-mailed me with a problem; he needed to add an XML DOM into another XML DOM, essentially making the first DOM a child node of the first one. Simple assignments returned the following error: http://www.polesan.com

    WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.

    The problem is that ColdFusion will not allow a DOM to be directly assigned to another DOM. The solution is to simply add the desired nodes and elements one by one using the XMLElemNew() function. http://www.livcon.co.uk

  • ya?am koçlu?u

    I.E. How do you join this xml:

    <shoppingList>
    <fruits>
    <apples>5</apples>
    <bananas>5</bananas>
    </fruits>
    </shoppingList>

    thanks for shaing