DOM appendChild??

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Juliano Freitas

    #1

    DOM appendChild??

    I have to append in a xml file as a child another xml file. How can i
    get this?

    i try parent.appendCh ild(document)

    but doesnt work!!

    Juliano Freitas

  • Thomas Guettler

    #2
    Re: DOM appendChild??

    Am Sun, 31 Oct 2004 21:12:47 -0300 schrieb Juliano Freitas:
    [color=blue]
    > I have to append in a xml file as a child another xml file. How can i
    > get this?
    >
    > i try parent.appendCh ild(document)
    >
    > but doesnt work!![/color]

    Hi,

    this is not possible. Try to add the root node (top level
    tag).

    HTH,
    Thomas

    Comment

    • Andrew Clover

      #3
      Re: DOM appendChild??

      Juliano Freitas <jubafre@atlas. ucpel.tche.br> wrote:
      [color=blue]
      > I have to append in a xml file as a child another xml file. How can i
      > get this?[/color]
      [color=blue]
      > i try parent.appendCh ild(document)[/color]

      A node from one document can't directly be inserted into another. You
      need to call Document.import Node first. Also you can't put the
      Document node directly into a parent, because it is by definition the
      root object of the entire DOM tree. What you probably want to do is
      insert the root element node, which you can read with
      Document.docume ntElement:

      el= parent.ownerDoc ument.importNod e(document.docu mentElement, True)
      parent.appendNo de(el)

      --
      Andrew Clover
      mailto:and@doxd esk.com

      Comment

      Working...