• var childCollection = someNode.childNodes;
  • Microsoft Word Applied xml a toolkit for Programmers Wiley doc




    Download 2,96 Mb.
    Pdf ko'rish
    bet105/131
    Sana14.05.2024
    Hajmi2,96 Mb.
    #232039
    1   ...   101   102   103   104   105   106   107   108   ...   131
    Bog'liq
    Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers


    The above code shows how easy variable declarations are in JavaScript. myInt contains 
    an integer value, whereas someString contains the string “hello.” In the examples to 
    follow, the alert(...) function is used to display a string to a dialog box. This function allows 
    us to show the reader the behavior of many DOM methods and properties by displaying 
    their results to the screen with an alert(...) box.

    This piece of code produces an alert box that contains the string “hello” (see Figure 5.1).


    - 115 -
    Figure 5.1:
    Alert box.
    For those completely new to programming, especially with JavaScript, a primer might be 
    necessary. Briefly, a property is a variable that is attached to the object and is usually a 
    string, an integer, or another node object like a NodeList. For example, the nodeName 
    property on nodes is a string that represents the name of a node. On the other hand, a 
    method performs some sort of action and usually has parameters and a return value. For 
    example, the method called insertBefore(...) is used to place nodes into the tree. Methods 
    and properties can be accessed from the main object by using a period. 
    someNode.nodeName produces the nodeName property of the someNode node. Objects 
    can also be cascaded in this fashion. For example, someNode
    .
    childNodes.length 
    produces the length property found on the childNodes property, where childNodes is a 
    property of someNode. someNode.childNodes.length is a shortcut for assigning 
    childNodes to a variable and then using it.

    Enough about JavaScript. The examples in this section are quite straightforward, 
    because only one property or method is displayed at a time. The more involved scenarios 
    in later chapters bring the various concepts together in one place.
    Some basic knowledge of the DOM is also needed to understand the examples. The 
    chapter is organized in a reference style for easy access while programming. For the 
    first-time reader, a few methods and properties need to be briefly explained to 
    understand the examples. The documentElement property found on the Document node 
    points to the top most XML element. Looking at the following the XML data island, root is 
    the top most element; therefore documentElement is the root Element node.


    Download 2,96 Mb.
    1   ...   101   102   103   104   105   106   107   108   ...   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