TAILIEUCHUNG - XML Step by Step- P19

XML Step by Step- P19:Extensible Markup Language, or XML, is currently the most promising language for storing and exchanging information on the World Wide Web. Although Hypertext Markup Language (HTML) is presently the most common language used to create Web pages, HTML has a limited capacity for storing information. In contrast, because XML allows you to create your own elements, attributes, and document structure, you can use it to describe virtually any kind of information from a simple recipe to a complex database | Chapter 10 Displaying XML Documents Using Data Binding 333 TR ALIGN center TD IMG DATAFLD COVERIMAGE TD TD SPAN DATAFLD TITLE STYLE font-style italic SPAN TD TD SPAN DATAFLD AUTHOR SPAN TD TD SPAN DATAFLD BINDING SPAN TD TD SPAN DATAFLD PAGES SPAN TD TD SPAN DATAFLD PRICE SPAN TD TR TABLE BODY HTML Listing 10-9. Listing 10-8 is an XML document that contains a field named COVERIMAGE in each BOOK record. Each COVERIMAGE field contains the URL of a graphics file that stores an image of the book s cover. Listing 10-9 is the same HTML page as the one in Listing 10-2 except that at the beginning of each row is an additional cell TD element that contains an IMG element rather than a SPAN. The IMG element is bound to the COVERIMAGE field in the XML document and therefore displays the cover image for each book as you can see here Data Binding 10 334 XML Step by Step You can experiment with binding some of the other HTML elements listed in Table 10-1 to learn about their bound properties and how the elements use the data in the XML fields to which you bind them. Rendering HTML By default if an XML field s character data happens to include HTML markup the HTML element bound to that field treats and displays the markup characters as literal text. Consider for example the following SPAN element which is bound to the AUTHOR-BIO XML field SPAN DATASRC dsoInventory DATAFLD AUTHOR-BIO SPAN If the AUTHOR-BIO field contains an italic I element like this AUTHOR-BIO Henry James was an American author who lived from 1843 to 1916 and wrote lt I The Bostonians lt I and many other works of psychologically realistic fiction. AUTHOR-BIO the SPAN element would treat the HTML markup characters as literal text and would display the field as follows Henry James was an American author who lived from 1843 to 1916 and wrote I The Bostonians I and many other works of psychologically realistic fiction. With some of the bindable HTML elements such as SPANs you can assign the DATAFORMATAS attribute the