• Figure 5.4: DOMifier output of nodeValue XML example. nodeType
  • Table 5.3: nodeType Definition Node Type NodeType
  • Microsoft Word Applied xml a toolkit for Programmers Wiley doc




    Download 2,96 Mb.
    Pdf ko'rish
    bet109/131
    Sana14.05.2024
    Hajmi2,96 Mb.
    #232039
    1   ...   105   106   107   108   109   110   111   112   ...   131
    Bog'liq
    Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers


    element contents



    For the above example, the first alert produces hello
     
    as the result, and the second alert 
    produces element contents. Figure 5.4 shows Named- NodeMap attributes collection and 
    the NodeList childNodes collection. Notice that the attribute someAttribute and the Text 
    node containing element contents are both the first child of their collections. It should also 
    be noted here that to access the contents of an element, you need to drill down to the 
    Text node and check the Text node’s nodeValue property. For attributes, the nodeValue 
    property on the Attribute node can give the contents of the attribute. Of course, you could 
    also drill down to the Attribute’s Text node and get the nodeValue off that node for the 
    same result. In other words, the following two lines produce the same result.
    xml.documentElement.attributes.item(0).nodeValue
    xml.documentElement.attributes.item(0).childNodes.item(0).nodeValue
    Figure 5.4:
    DOMifier output of nodeValue XML example.
    nodeType
    Type
    : Unsigned short integer
    Description
    : This property is an integer value that represents the type of the node. Table 
    5.3 shows the correlation between nodeType and the different nodes.
    Table 5.3: nodeType Definition
     
    Node Type
    NodeType
     


    - 120 -
    Element
    1
    Attribute
    2
    Text
    3
    CDATASection
    4
    EntityReference
    5
    Entity
    6
    ProcessingInstruction
    7
    Comment
    8
    Document
    9
    DocumentType
    10
    DocumentFragment
    11
    Notation
    12
     
    The following six properties—parentNode, childNodes, firstChild, lastChild, 
    previousSibling, nextSibling—refer to other nodes in the same tree. Figure 5.5 shows 
    their relationship to a node picked out at random called CURRENT NODE. Also, nodes 
    that have their description in parentheses are not directly accessible from CURRENT 
    NODE, but are still accessible indirectly through another node.

    Download 2,96 Mb.
    1   ...   105   106   107   108   109   110   111   112   ...   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