• var elem1 = xml.documentElement.childNodes.item(0); var elem2 = xml.documentElement.childNodes.item(1); elem1.appendChild( elem2.childNodes.item(0) );
  • Figure 5.7: DOM representation of original XML document in appendChild example. Figure 5.8
  • Microsoft Word Applied xml a toolkit for Programmers Wiley doc




    Download 2,96 Mb.
    Pdf ko'rish
    bet113/131
    Sana14.05.2024
    Hajmi2,96 Mb.
    #232039
    1   ...   109   110   111   112   113   114   115   116   ...   131
    Bog'liq
    Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers

    appendChild(newChild)
    Parameters
    : newChild
     
    is a Node.
    Return value
    : None
    Exceptions thrown:
    DOMException
    Description:
    newChild is added to the end of the list of children. If newChild was located 
    somewhere else in the tree, then it is first removed from that location before being added 
    to the current list of children.
    Comments:
    In Internet Explorer 5, newChild is returned.
    Example
    :













    After the script is run, the resulting XML document is:



    - 125 -







    The appendChild method automatically removed childElement2 from the child list of 
    elem2, before inserting it into the child list of elem1. Figures 5.7 and 5.8 shows the before 
    and after DOM representation of this XML document.
    Figure 5.7:
    DOM representation of original XML document in appendChild 
    example.
    Figure 5.8:
    DOM representation of XML document after childElement2 is moved.
    hasChildNodes()
    Parameters
    : None
    Return value
    : Boolean
    Exceptions thrown
    : None
    Description
    : This method returns
     true
    if this node has children and 
    false
    otherwise.
    cloneNode(deep)
    Parameters

    deep
    is a Boolean value.
    Return value
    : Node
    Exceptions thrown:
    None
    Description
    : cloneNode is used to produce a copy of the node that it is called on. For 
    those familiar with object-oriented programming terminology, this function fulfills the role 


    - 126 -
    of a copy-constructor. If deep is false, then the node is copied, but its children are 
    ignored. If deep is true, then a complete replica of the subtree starting at the current node 
    is returned.
    Comments
    : Calling cloneNode(true) can result in a very processing-intensive operation, 
    especially if called on the Document node of a large document.
    Document
    Parent
    : Node
    The Document node is not an element; rather it represents the document as a whole. In 
    data islands, the id attribute on the  tag is a reference to the Document node.
    The Document node is the root node that contains the facilities to manage the various 
    nodes beneath it. More specifically, the Document node is used to create nodes that can 
    later be inserted into the tree. Also included is a basic searching mechanism. In addition 
    to these facilities, the Document node contains pointers to other important nodes in the 
    tree, such as the root Element node and the DocumentType node. 

    Download 2,96 Mb.
    1   ...   109   110   111   112   113   114   115   116   ...   131




    Download 2,96 Mb.
    Pdf ko'rish

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Microsoft Word Applied xml a toolkit for Programmers Wiley doc

    Download 2,96 Mb.
    Pdf ko'rish