920 Part III (Frontpage web hosting) . Document Objects Reference Chapter
Friday, February 29th, 2008920 Part III . Document Objects Reference Chapter 15. Note describe an individual s contact information with one set of elements, while another application uses a completely different approach to element names, element nesting, and their sequence. Fortunately, most, if not all, scripting you do on XML data is on data served up by your own applications. Therefore, you know what the structure of the data is or you know enough of it to let your scripts access the data. The discussion of the W3C DOM in Chapter 14 should serve as a good introduc tion to the way you need to think about elements and their content. All relevant properties and methods are listed among the items shared by all elements in Microsoft has created a separate document object model exclusively for XML documents. To distinguish between the DOMs for XML and HTML documents, Microsoft calls the former the XML DOM and the latter the DHTML DOM. Specifications for the two DOMs overlap in some terminology, but the two models are not interchangeable. Read more about the Microsoft XML DOM at http:// msdn.microsoft.com. An XML data island is a hierarchy of nodes. Typically, the outermost nodes are elements. Some elements have attributes, each of which is a typical name/value pair. Some elements have data that goes between the start and end tags of the element (such data is a text node nested inside the element node). And some elements can have both attributes and data. When an XML island contains the equivalent of multiple database records, an element container whose tag name is the same as each of the other records surrounds each record. Thus, the getElementsByTagName() method frequently accesses a collection of like- named elements. Once you have a reference to an element node, you can reference that ele ment s attributes as properties; however, a more formal access route is via the getAttribute() method of the element. If the element has data between its start and end tags, you can access that data from the element s reference by calling the firstChild.data property (although you may want to verify that the element has a child node of the text type before committing to retrieving the data). Of course, your specific approach to XML elements and their data varies with what you intend to script with the data. For example, you may wish to do nothing more with scripting than enable a different style sheet for the data based on a user choice. The evolving XSL (eXtensible Stylesheet Language) standard is a kind of (non-JavaScript) scripting language for transforming raw XML data into a variety of presentations. But you can still use JavaScript to connect user-interface elements that control which of several style sheets renders the data. Or, as demonstrated in Chapters 52 and 57, you may wish to use JavaScript for more explicit control over the data and its rendering, taking advantage of JavaScript sorting and data manipu lation facilities along the way. Table 33-1 is a summary of W3C DOM Core objects, properties, and methods that you are most likely to use in extracting data from XML elements. You can find details of all of these items in Chapter 15.
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.