• Figure 4.5: DOMifier display of Figure 4.4 . Different Node Types
  • Figure 4.1: Tree model. DOMifier




    Download 2,96 Mb.
    Pdf ko'rish
    bet97/131
    Sana14.05.2024
    Hajmi2,96 Mb.
    #232039
    1   ...   93   94   95   96   97   98   99   100   ...   131
    Bog'liq
    Ceponkus, Hoodbhoy - Applied XML - Toolkit for Programmers

    Figure 4.1:
    Tree model.
    DOMifier
    While reading 
    Chapters 4
    and 
    5
    , you are encouraged to try to see for yourself what the 
    DOM exposes for different XML documents. We have put together a learning utility called 
    the DOMifier to show what the DOM exposes. This utility can be found on the CD, and 
    the source code to the DOMifier is in 
    Chapter 10
    to show how the DOM can be used from 


    - 102 -
    Visual Basic. The diagrams presented in the next section can be easily verified by 
    copying the XML snippets into a file and then loading them in with the DOMifier. 
    Changing a few lines around and reloading can help you get a feel for what the DOM 
    exposes much faster than just reading alone. Figure 4.5 shows an example of the 
    DOMifier output.
    Figure 4.5:
    DOMifier display of
    Figure 4.4
    .
    Different Node Types
    A brief description of each node type is given below, and an in-depth look at each node is 
    provided in later chapters.
    Each of the following node types is derived from a base class called Node. A developer 
    never creates a generic node, but rather creates one of the following nodes to model the 
    appropriate behavior of a fragment of an XML document. Each of these nodes can 
    identify themselves through the nodeType property. A numerical value is assigned to 
    every node, and the nodeType returns the numerical value associated to a particular 
    node. Details about the nodeType property are described in 
    Chapter 5
    .
    Document.
    The Document node is the master node; only one of these nodes can exist 
    for an XML document. This node is the top-most parent node and represents the XML 
    document as a whole. In other words, the document node doesn’t represent any specific 
    piece of the XML document. This node has the special functionality to create other 
    nodes, which can then be inserted into the tree.
    NodeList.
    A NodeList node is used to hold a collection of child nodes. This node can 
    also tell the parent how many children are present, a feature that is useful in loops. Not 
    all nodes can have children; that is, not all nodes can have a NodeList collection. 
    Conceptually, the NodeList is just a facility to gain access to the children of a given node. 
    Figure 4.2 shows a simple tree: a parent and three children. Figure 4.3 shows how a 
    NodeList node is like any other node in a model, but is used only to group the children. 
    This NodeList facility provides a uniform mechanism for accessing child nodes.

    Download 2,96 Mb.
    1   ...   93   94   95   96   97   98   99   100   ...   131




    Download 2,96 Mb.
    Pdf ko'rish