• event on the // tag. function start() { // Putting the number of children of the node is a
  • Figure 5.9: DOM tree before normalize(). Figure 5.10




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

    Figure 5.9:
    DOM tree before normalize().
    Figure 5.10:
    DOM tree after normalize().
    Element Usage Examples
    The following are several examples of element usage.
    Iterating through Children
    Often it is necessary to perform some sort of action to every child of a node. Using the 
    childNodes collection and a for loop, visiting each child is quite easy. The start() method 
    is automatically called when the document is loaded because of the onload event on the 
    tag. The function then visits each child node to check if it’s an Element node. If 
    so, the tag name is displayed. A true iterating facility would indeed be a nice addition to 
    the DOM specification. For those who are unfamiliar with iterators, an iterator facility 
    would allow a programmer to ask for the next child through a method instead of with 
    indexes.

    onload="start()"
    >

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




    Download 2,96 Mb.
    Pdf ko'rish

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Figure 5.9: DOM tree before normalize(). Figure 5.10

    Download 2,96 Mb.
    Pdf ko'rish