• // Start the process with the next line. // This function is called when the document is loaded. // Note that this function responds to the onload
  • // This function displays all the Text and CDATASection nodes of a // given node. function displayContents(node) {
  • for (index = 0; index var childNode = node.childNodes.item(index);
  • outputBuffer += childNode.nodeValue; } // If the child node is of type CDATASection, then // add its contents to the output buffer.
  • // Now that we have built up the output buffer, it can be // displayed through an alert box. alert(outputBuffer); }
  • alert(childNode.nodeName)




    Download 2,96 Mb.
    Pdf ko'rish
    bet121/131
    Sana14.05.2024
    Hajmi2,96 Mb.
    #232039
    1   ...   117   118   119   120   121   122   123   124   ...   131
    Bog'liq
    Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers


    onload="start()"
    >

    tag. start() then 
    passes visit(...) the first element, the documentElement, and then visit(...) takes over. 


    - 137 -
    visit(...) checks if the node that is passed to it is an Element node; if so, the tag name for 
    the element is displayed to the user through an alert box. The function then performs the 
    same action on the children with a depth-first traversal of the tree. Depth-first means that 
    the function goes as deep as possible before visiting siblings. The other type of traversal 
    is referred to as a breadth-first traversal, where all the siblings are first visited and then 
    the children.


    Download 2,96 Mb.
    1   ...   117   118   119   120   121   122   123   124   ...   131




    Download 2,96 Mb.
    Pdf ko'rish