• Tree Management Examples A few examples of using the Node and Document methods are presented here to bring together some actual scenarios of DOM usage. Creating Nodes
  • Microsoft Word Applied xml a toolkit for Programmers Wiley doc




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

    createTextNode(data)
    Parameters

    data
    is a string value.
    Return value
    : Text node
    Exceptions thrown
    : None
    Description
    : Creates and returns a new Text node that contains the string 
    data
    .
    createComment(data)
    Parameters

    data
    is a string value.
    Return value
    : Comment
    Exceptions thrown
    : None
    Description
    : Creates and returns a new Comment node that contains the string 
    data
    .
    createCDATASection(data)
    Parameters

    data
    is a string value.


    - 128 -
    Return value
    : CDATASection
    Exceptions thrown
    : None
    Description
    : Creates and returns a new CDATASection node that contains the string 
    data
    .
    createProcessingInstruction(target, data)
    Parameters

    target 
    and
     data
    are string values.
    Return value
    : ProcessingInstruction
    Exceptions thrown
    : None
    Description
    : Creates and returns a new ProcessingInstruction node and sets the 
    ProcessingInstruction properties target and data to the given parameters 
    target
    and 
    data

    See the 
    ProcessingInstruction
    section later in this chapter for an explanation of target and 
    data.
    createAttribute(name)
    Parameters

    name
    is a string value.
    Return value
    : Attribute
    Exceptions thrown
    : None
    Description
    : Creates and returns a new Attribute node and sets the nodeName property 
    to 
    name
    . The nodeValue property is left blank.
    createEntityReference(name)
    Parameters

    name
    is a string value.
    Return value
    : EntityReference
    Exceptions thrown
    : None
    Description
    : Creates and returns a new EntityReference node and sets the nodeName 
    property to 
    name
    .
    getElementsByTagName(tagname)
    Parameters

    name
    is a string value.
    Return value
    : NodeList
    Exceptions thrown
    : None
    Description
    : Returns a list of Element nodes that have a property tagName (or 
    nodeName) that matches the parameter name name. This method searches the whole 
    tree that belongs to the Document node. If name equals “*", then all the Element nodes 
    are returned.


    - 129 -
    Comments
    : This method performs the same operation as the 
    getElementsByTagName(name) method that is found on the Document node. The 
    Document node’s getElementsByTagName(name) searches the whole tree, whereas the 
    Element’s method searches only the subtree of the Element on which it was called.
    Tree Management Examples
    A few examples of using the Node and Document methods are presented here to bring 
    together some actual scenarios of DOM usage.
    Creating Nodes
    This example shows how to create a new Element node and insert it into the tree. 
    createElement(...) is used to create the new Element node, and insertBefore(...) is used 
    to insert it into the tree. The second parameter is set to null because we want to insert 
    new Element node to the end of the list. The xml property on the Document node, also 
    called xml, is used to show the resulting XML document. The xml property is a Microsoft 
    extension, which means it only works in MSXML (it is described in more detail in 
    Chapter 
    7
    ).


    Download 2,96 Mb.
    1   ...   111   112   113   114   115   116   117   118   ...   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