span> td> span> td> span> Td> span> td> span> td> tr> table> Body> html>
Inventory.xml file Links to the Data ISland of DSoinvent in the web page, link to the list inventory table.htm HTML page:
xml>
By setting the DataSRC property of the table element in the web page, the Table element will be connected to the entire XML file with an arithmetic symbol (#) character.
form is defined with a standard title (THEAD element) defined by a column (TR element). Each column (i.e., each TD element) contains a SPAN element that is connected to the field of the XML file to allow the element to display the content of the field. For example, the first column contains a span element that links to the title field:
span> td>
The SPAN element is connected to the XML field by setting the name of the field to the DataFld property of the element (in this example, it is Title). Below is a mode of operation of the data link: Although the table element only defines a single column, when the browser displays the table, it repeats the column elements for each record in the XML file. That is, the first column that follows the title shows a field belonging to the first record (Title, Author et al.). The next column is the second record (for the Book element of Leaves of Grass), the third record, and the like display fields. Here is the look at the inin of Internet Explorer 5:
Http://jyan.w148.4everdns.com/lycos/xml/images/1.gif
You may doubt why the column (TD) element is not directly connected to the XML field. The reason is that the TD element is not a connected HTML element. (Table 8-1 in page 295 lists the canable elements.) So, you need to include a connectable element, usually span, in each TD element.
prompt
To get more about the operations of HTML and DHTML described in Chapter 5, see the website listed on http://msdn.microsoft.com/Workshop/author/default.asp on MSDN. To refer to the official HTML specification, see the information provided by the WorldWide Web Consortium (W3C) website http://www.w3.org/tr/rec-html40/.
Use pagings
If the XML file contains a lot of records, you can display records in a group in a group, not all records in a lengthy table. To start a paging feature for a particularly connected table, perform the following steps:
1. Set the DataPageSize property of the connected table element to the maximum number of records you want to display once. That is, each page recorded will contain the number of records you specify. For example, the starting tab of the table element specifies 5 as the attribute value for the DataPagesize property, which will cause only 5 records to be displayed at a time:
2. Specify a unique identification code for the ID attribute of the Table element, as shown in the following starting tag:
3.
4. To view inter-record, you can call the method of table elements in the table below. Note that the example in the last line is a hypothesis that the table has an id value of the InventoryTable.
Table element method affects call example
----- FirstPage Display Record of InventoryTable.firstpage () ----- PreviousPage Display Record Previous InventoryTable.Previouspage () ----- NextPage Display Record Next InventoryTable.NextPage ) ----- LastPage Display Last page inventoryTable.lastPage ()
If the first page is currently displaying, the call previouspage method is ignored, not working; if it is displaying the last page, the call nextpage method will be ignored. You can use Script to call any of these methods (as will be discussed later in this chapter). However, the simplest way is to set the method to the onclick property of the Button element in the HTML, as shown below:
http://jyan.w148.4everdns.com/lycos/xml/images/2.gif
Inventory big.xml -----------------
xml version = "1.0"?> the adventures of huckleberry finn title> Mark Twain authoror > mass market paperback binding> 298 pages> $ 5.49 price> book> The Adventures of Tom Sawyer Title> Mark TWAIN author> mass market paperback binding> 205 piece> $ 4.75 price> book> The Ambassadors title> Henry James author> mass market paperback binding> 305 pages> $ 5.95 The awakenging title> Kate Chopin author> mass market paperback binding> $ 4.95 price> book> billy budd title> < Author> Herman Melville Author> Mass Market Paperback Binding> $ 4.49 price> a connectionicut yankee in king arthur 'Scourt title> Mark Twain author> mass market paperback binding> 385 month $ 5.49 < / Price> book> joan of arc title> Mark Twain author> Trade Paperback binding> 465 pages> $ 6.95 Price> book> Leaves of grass title> <
Author> Walt Whitman author> Hardcover binding> 462 pages> $ 7.75 price> book> The Legend of Sleepy Hollow Title > Washington Irving author> mass market paperback binding> 98 pages> $ 2.95 price> book> the marble faun The Marble Faun / Title> Nathaniel Hawthorne author> Trade Paperback binding> $ 10.95 moby-dick Title> Herman Melville author> hardcover binding> $ 9.95 price> book> passing Title> Nella larsen author> Trade Paperback binding> 165 pages> $ 5.95 price> book> The portrait of a Lady title> Henry James author> mass market paperback binding> 256 pages> $ 4.65 Roughing it title> Mark Twain author> mass market paperback binding> $ 5.25 pages> $ 5.25 price> book> The scarlet letter title> Nathaniel Hawthorne author> Trade Paperback binding> $ 4.25 price> book> The Turn of The Screw <
/ Title> Henry James author> Trade Paperback binding> 384 pages> $ 3.35 price> book> inventory> List 8-3.
Inventory Big Table.htm -------------------------! - File Name: Inventory Big Table.htm ->
book inventory title> head> xml> book inventory h2> | Next Page> < / Button> Author th> Binding TH> Pages TH> Price TH> THEAD> span> td> < / Span> td> span> td> span> td> span> td> tr> table> body> html> list 8-4.
Use nest form to display class record set
In the previous chapter, you have learned how to use a single table to display XML files constructed in a simple recordset, each record contains a fixed set of fields, all of which only store character data. Now you will learn how to use nest forms to display specific XML files, the element of this XML file is constructed in classic recordset. In the classic record set, each record may contain a set of numerous nest records (zero or more) in addition to the fixed set of fields. Listing 8-5 shows an example of XML file constructs constructed to build a hierarchy recording set. (You can find in the Inventory Hierarchy.xml file with the book CD.) In this file, the root element contains a series of Category records. Each Category record is initiated by a CATName field, which only contains character data. The back is then zero or multiple nest BOOK elements. Each neopic book element has five fields (Title, Author, Binding, Pages and Price). Inventory hierarchy.xml -----------------------
XML Version = "1.0"?> Middle Ages CATNAME> The canterbury taTeles Title> Geoffrey chaucer author> hardcover binding> 692 pages> $ 18.95 price> book> Piers Plowman Title > William Langland author> Trade Paperback binding> 385 pages> $ 10.95 price> book> Renaissance Catname> The blazing world title> Margaret Cavendish author> Trade Paperback binding> $ 8.79 price > Book> Oroonoko title> Aphra behn author> mass market paperback binding> $ 4.95 price> $ 4.95 price > Book> Doctor Faustus title> Christopher Marlowe author> Hardcover binding> 472 pages> $ 15.95 price> Book> category> 18th Century catname> gulliver's travels title> Jona Than Swift author> Hardcover binding> 324 pages> $ 11.89 price> book> The History of Tom Jones: Afoundling TITLE > Henry Fielding author> <
Binding> Hardcover Binding> $ 16.95 price> love in excess title> eliza haywood author> < Binding> Trade Paperback binding> 429 page> $ 12.95 Tristram shandy title> Laurence Sterne author> < Binding> Hardcover Binding> $ 9.49 price> 19th Century catname> Dracula Title> bram stoker author> hardcover binding> 395 pages> $ 17.95 price> book> Great Expectations < / Title> Charles Dickens author> mass market paperback binding> 639 page> $ 6.95 Percival Keene Title> Frederick marryat author> Trade Paperback binding> 425 pageES> $ 12.89 book> treasure island Title> Robert Louis Stevenson Author> Trade Paperback binding> 283 pages> $ 11.85 price> book > Wuthering Heights title> Emily bronte author> hardcover binding> $ 12.95 < $ 12.95 price> book> Category> inventory> List 8-5.
Listing 8-6 includes an HTML web page that uses a nest form to display the class record structure of the XML file in the list 8-5. (You can find it in the Inventory Hierarchy.htm file with the book CD.)
Inventory hierarchy.htm -----------------------
inventory of classic english literature title> head> Classic English Litrate TH> thead> span> < TH> Title th> Binding TH> Pages TH> Price TH> thead> span> td> span> td> span> td> span> td> span > Td> tr> table> td> tr> table> body> html> list 8-6.
In Listing 8-6, the external table is connected to the XML file, and you can see the following in its starting tag;
The external table also contains a title (this is a THEAD element showing "Classic English Literature", plus the columns of the two tables (two TR elements). The browser will repeat these two columns for each top recording (ie, each Category record). The first two columns show the CATName field. So far, everything works like a sample table of the simple recordset in Listing 8-2. However, the second column contains a nest-like table that displays the contents of each Book record in the current directory, not the display field. Here is a volume label only for nest form:
Author th> Binding TH> Pages TH> Price TH> THEAD> span> td> span> TD> span> td> span> td> tr> table>
Note that you must link the nest form to not just an XML file (DatasRC = # "# dsoinventory), and there is a nest Book record (DataFld =" book "), so the table will display the current category in a nest. Record the contents of each BOOK element. In other words, the column elements (TR) in the table will repeat each of these BOOK elements. (Note that according to the default, the external table is connected to the top of the element - the category record in the example - so it will display each record in step.)
Below is it when you turn the list 8-6 in Internet Explorer 5, the list looks like:
http://jyan.w148.4everdns.com/lycos/xml/images/3.gif
You can use an additional nest form to display files that contain several nest records. For example, refer to the example file of the list 8-5. Suppose you have changed every author field:
Geoffrey chaucer author>
Change to zero or multiple nest Author records:
Geoffrey firstname> chaucer lastname> author> In this case, you can use additional nest forms for every Book element, show all the author, this is Util the same technique as used in a single tissue form.
Use a single recorded data link
Single-Record Data Binding refers to an HTML element that is not a table, and it is not included in the connected table. HTML elements - such as span, button or label elements - are connected to individual XML fields. The HTML element will then automatically display the contents of the XML field they are connected. For example, the SPAN element of the following HTML is connected to the Title field of the XML file, which is accessed by Data Island named DSOBOOK:
span>
However, because the HTML element is not like a table, it can only display the value of the field once a record. To use a single recorded data link, the XML file must be composed of a simple record set. The simple record set introduced in the Chapter of the Simple Record Set in this chapter is already using the individual HTML forms.
The simplest example of the data link of a single record is to use the XML file containing only a record, such as the sample file in the list 8-7. (You can find it in the book.xml file with the book CD.)
Book.xml ---------- XML Version = "1.0"?> The Adventures of Huckleberry Finn Title > Mark Twain author> mass market paperback binding> $ 5.49 price> book> list 8-7.
Listing 8-8 shows an HTML web page that connects individual SPAN elements to each field (title, author, binding, pages and Price). (You can find it in the book.htm file with the book CD.)
Book.htm -----------
book description title> head> < XML ID = "DSOBOOK" src = "book.xml"> xml> book description h2> Title: span> span> author: span> span> binding type: span> span > Number of page: span> span> span> body> html> list 8-8. Below is the Internet Explorer 5 display Listing 8-8 look:
Http://jyan.w148.4everdns.com/lycos/xml/images/8-8.gif
Browse data records
If the XML file contains more than a record (up to them can be included), a single recorded data link becomes a bit complicated because the HTML element can only display a record at a time. Records displayed by HTML elements are called Current Record. (Therefore, another alternative method of single record link is current-record binding, called current record link) At the beginning, the current element is the first (or unique) record in the file. DSO combined with XML files provides a set of methods to make you call on intercombacter. These methods belong to the DSO recordset member object and is listed in the table below. Note that in the last line example call is assumed that the HTML web page contains an XML Data Island, its ID is DSOINVENTORY.
DSO record set method (Note: It is a table) --------------------------------------- ---------- Call the current record into the first record of the call sample file MoveFirst MoveFirst ()
Previous record DSoinventory.Recordset. MovePrevious moveprevious ()
Next record DSOINVENTORY.Recordset. Movenext MoveNext ()
The last record in the file DSoinventory.Recordset. MoveLast Moveset ()
Specific number of records DSOINVENTORY.RecordSet.move DSoinventory.RecordSet.Move (5) Move to the 6th record. The record is starting from 0. ) ------------------------------------- -
Note ------ DSO recordset member object complies with Microsoft Call ActiveX Data Objects (ADO) standard data access technology. You can use a general ADO record set object, as well as a variety of data from the XML DSO described in this chapter. For more information on ADO and Ado records, please refer to Microsoft, located at http://www.microsoft.com/data/ado/default.htm. For a specific record set, please refer to http://msdn.microsoft.com/library/psdk/dasdk/mdap2y7s.htm. You can call any of these methods from the script you write (such as this chapter will be introduced later). However, calling these methods are the simplest way, that is, by specifying the method to the onclick property of the Button element, as shown below:
Back button>
The following program fixes the status of the end of the file:
xml> book description h2> Title: span> span> Author: span> span> binding type: span> span> Number of page: span> Span> price: span> span> | & lt; First BUTTON> & LT; back button> Forward & gt; BUTTON> Last & gt ; Button> body>
Html> List 8-9.3. In the Windows Archive General or Directory window, double-click the file name - Inventory Single.htm, this is the file you store in the previous step: Internet Explorer 5 will turn on and display the file ,As shown below:
http://jyan.w148.4everdns.com/lycos/xml/images/single.gif
Note that from the beginning, until the user starts to click the button, both the Internet Explorer 5 only displays the first record of the file. Other Data Link Technology In the next chapter, you will learn a number of additional techniques for linking the HTML elements of non-format. These techniques may be individual HTML elements used as a single recorded data link, or HTML elements contained in the connected HTML table. In particular, you will learn: How to connect the HTML element to the XML field. How to make the HTML tag in the XML field. How to update XML data in the cache
Table 8-1 summarizes important information to use when you study follow-up chartes. Table lists you can be used to perform HTML elements of a single record data link - that is, in addition to all of the Table Elements other than the Table element. The table describes the purpose of each element. Specifies a particular purpose that is coupled to the XML field element, whether or not the element can be implemented in the HTML volume label included in the XML field connected to the element, and display the content of the elements to update the content of the XML field. . This information is not much more significant before you study the next chapter, and you will provide you with reference. Table 8-1.
The connected HTML element (does not include a Table element). Form: http://jyan.w148.4everdns.com/lycos/xml/linkenable.htm
As you can see, when you connect the SPAN element to the XML field, the element simply displays the contents of the field. This is because the SPAN element's InnerText property - is responsible for setting the element to which the element is to be displayed - is connected to the XML field.
Note ---- In DHTML, each HTML element has a set of properties that you can use to set or read elements different characteristics through the Script program. Internet Explorer 5 has support DHTML. At the same time, as explained in this section, the attribute will automatically be set from the value of the XML field it connects. However, Table 8-1 shows the use of some can be coupled HTML elements, and other properties are connected to the XML field. Note that a SPAN element is actually connected to its InnerText and Inner-HTML properties. The Innertext property sets or acquires text content in the element, but does not contain an HTML tag. The Inner-HTML property is the entire content of the setting or acquisition element, containing any HTML tag.
For example, using a connection A (anchor) element (anchor, it is used to create a hyperlink), the HREF attribute is connected to the XML field, as shown below:
Click Here for Reviews
This property is like the HREF attribute of the element, which is responsible for setting the destination URL of the hyperlink. Therefore, the destination URL of the coupled A element is derived from the XML field (the REVIEWS XML field in the examples must of course be a complete URL), not its text content.
In another example, the CHECKED Properties - Check Attributes Responsible for changing the elements - the XML field is ligated to the XML field, as shown below:
If the Instock XML field is empty, or it contains text "0" or "false", the check square will be cleared. If it contains any other text, the check square will be selected.
In the last example, the IMG (image) element is used, the SRC property is connected to the XML field. This property, like the Element's SRC element, indicates the URL that contains the graphics data file. Listing 8-10 and 8-11 describe the skills of connecting IMG elements. (You can find it in the inventory image.xml file with the book CD and the Inventory Image Table.htm file.)
Inventory image.xml --------------------- XML Version = "1.0"?> < Inventory> Leaves.bmp coverImage> Leaves of grass title> Walt Whitman author> hardcover binding> 462 pages> $ 7.75 price> book> Legend.bmp coverImage> The legend of sleepy hollow title> Washington Irving author> mass Market Paperback Binding> 98 pageES> $ 2.95 moby.bmp coverImage> moby-dick title> < Author> Herman Melville author> Hardcover binding> 724 pages> $ 9.95 price> book> inventory> List 8-10.
Inventory Image Table.htm -----------------------------! - File Name: Inventory Image Table.htm ->
book inventory title> head> xml> book inventory h2> < Table DatasRC = "# dsoinventory" border = "1" cellpadding = "5"> Cover th> title tH> Author th> Binding < / TH> Pages TH> Price TH> THEAD> span> td> span> td> span> td> span> td> TR> Table> body> html> List 8-11. Listing 8-10 is an XML file that contains a field named Cover-Image in each Book record. Each Cover-Image field contains a URL that stores a book cover graphical file. Listing 8-11 is the same HTML web page as list 8-2, except that the starting portion of each column is more than one column (TD element), which contains an IMG element instead of the span element. The IMG element is coupled to the CoverImage field in the XML file, so it displays the image of each book cover, as shown in the following figure:
http://jyan.w148.4everdns.com/lycos/xml/images/8-10.gif
You can take a part of the other HTML elements in Table 8-1 to learn how to connect these elements, and how the elements use data in the XML field when you connect these properties. Performance HTML According to the preset, if the character data of the XML field happens to include the HTML volume label, the HTML element linking to this field will handle these volumes with Literal text. Type. For example, consider the following SAPN elements, they are connected to the Author-BIO field:
span>
If the Author-BIO field contains a bevel word (i) element, it is like this:
Henry James Was An American Author Who Lived from 1843to 1916, And Wrote The Bostonians and many Other Works ofpsychologically realistic fiction. Author-bio>
The span element will treat the characters of the HTML volume as a literal text and the display field is as follows:
Use some canable HTML elements such as SPAN. You can set the value of the DataFormatas property to "HTML" to drive the browser to process the HTML volume label in the field text, not just regarded it as a Litral character. For example, suppose you will define the previously displayed sample SPAN elements:
span>
It will then put the text within the I element to berterally arranged, as shown below:
Note ------ To DataFormatas Set the default value "Text", which simply omits the same effect, which makes the HTML volume labeled characters are treated as Litral text. To find out which elements are you can use to schedule HTML through the attribute settings of Data-Formatas = "HTML", see Table 8-1. These elements are "YES" in the penultimate field (marked as "HTML" included in the XML field). Especially useful when adding to the format of the HTML for modifying the text section (for example, using I or B element) in the XML field (for example, using i or b), and the HTML element such as hyperlinks or images is particularly useful. Although XML text violates the basic principles of separation data and format arrangements by using the HTML tag in XML, this tip may be a modified format or the only feasible in the field of HTML elements in the field. Methods. (Conversely, if you use this book to display the other ways of XML, by including the brackets and appropriately handle them, you can modify the format or add the elements to the XML element.) When you join the HTML tag to When you are in the XML field, you cannot add (<) or (&) symbols to the text. (Memories, these characters are inelastic in the character data of the elements.) However, you can use the pre-defined entity to refer to "& lt;" and "& amp;", add them to the text. Another option will make HTML more readable and is particularly useful to the HTML of the large block, and the method is to include the label in the CDATA section, as discussed in Chapter 4. Updating the XML data XML DSO in the Complete Buffer Save allows you to modify XML data in several ways. However, before you extremely excited for this possibility, remember that these techniques only modified the DSO to temporarily get a copy of XML data in memory, not the original XML file on the server. Unless you use a quite complex technique to change files on the original server (this has exceeded the scope of this book), the utility of XML data on the cache is limited, and here I just simply be introduced. By connecting the modified HTML element to a specific XML field, you can make the user to modify the XML field, such as the INPUT element of the Text type. The top right representative in Table 8-1 allows the user to modify the HTML element of the XML field that is coupled to the element.
For example, if you connect the INPUT element of the Text type to the Title field, not the SPAN element to the title field, as shown below, but the user can also browse the contents of the title element, but also edit its content:
At the same time, the DSO's Recordset member object provides a way to add or remove the entire record from the recordset on the cache, and cancel the pair Record the modification of the set. Note that at the last line call example assumes that the HTML web page contains an XMLData island, its ID is DSOINVENTORY.
DSO record set method
Impact call example
AddNew
Add a new record to a quick record set in dsoinventory.recordset.addNew ()
DELETE removes the current record from the quick record set concentrated DSOINVENTORY.RecordSet.delete ()
Cancelupdate reserves the modifications made to the current record, or cancel the new records to remove DSOINVENTORY.Recordset.cancelupdate () Use DTD and Data Links
So far, every sample file you have seen in this chapter has a format correct XML file, which does not contain file type declaration (DTD). However, if you are using a data link to display an XML file, contain DTD and make sure that the file is valid. When you define the element of the file, you will help you ensure that you meet the requirements of the symmetric recordset. DTD also helps ensure that the DSO property is applied from the elements in the file to properly build its cache recordset. Contains DTDs are especially useful for having a more complex hierarchy record structure, you can be displayed in the nest. The file in Listing 8-5 is such an example. In the following exercises, you will add a DTD to the file to make the file valid and make sure the file is in line with the record structure required by the data link. Note that if you contain any valid errors in the XML file displayed by the data link, the information will not be displayed in the connected element, but you will not see any error messages. To view any wrong auxiliary narrative in the connected XML file, use the validity of the XML file in Chapter 9 to check the validity and formatting correctness check Script to test files.
caveat
When you make a declaration of an element (such as the Category or Book element in Listing 8-12), you must include a content model that explicitly lists all recorded fields and neo records. You can't use the ANY content rules, which will cause the data link to fail.
Establish an effective XML file for the data link
1. In the text editor, open the inventory hierarchy.xml file you established earlier this chapter. (You can find this file with the list 8-5 and the following book CD.)
2. On the component of the file, enter the following file type announcement:
3. [DOCTYPE INVENTORY4 "[5. 6. 7. 8. 9. 11. 12. 13. 14.]>
These elements can be explained that the language of the record set and the data link is as follows:
o file contains zero or multiple Category records. O Each Category record contains a category field, followed by zero or multiple nest Book records. O Each nest Book record contains only one of the following backfields, in accordance with the order is Title, Author, Binding, Pages and Price. o and the rest of the announcement. The fields in each Book record contain only character data. 15. To reflect the file name to set, the annotation of the file started from
Change to:
16. Save the new file instruction using the text editor to store the modified file in Inventory
Hierarchy Valid.xml. A complete XML file is displayed in Listing 8-12. (You can find it in the Inventory Hierarchy Valid.xml file with the book CD.)
Inventory hierarchy valid.xml ---------------------------- XML Version = "1.0"?> ]> Middle Ages catname> the canterbury tales title> geoffrey chaucer author> hardcover binding> $ 18.95 pages> $ 18.95 price> book> Piers Plowman title> William Langland author> trade Paperback binding> $ 10.95 pages> $ 10.95 price> Renaissance catname> The blazing world title> Margaret Cavendish author> Trade Paperback binding> 225 pages> $ 8.79 price> book> Oroonoko tit Le> Aphra Behn author> mass marketpaperback binding> $ 4.95 price> book> Doctor Faustus Title> Christopher Marlowe author> hardcover binding> 472 pageES> $ 15.95 price> book>
Category> 18th Century catname> gulliver's travels title> jonathan swift author> hardcover binding> 324 < /PageS>< Priced (Prica) $ 11.89<< Henry Fielding author> hardcover binding> < Pages> 438 pages> $ 16.95 price> book> love in excessed title> eliza haywood author> trade paperback binding> $ 12.95 pages> $ 12.95 price> Tristram shandy title> laurence sterne author> hardcover binding> < Pages> 322 pages> $ 9.49 price> book> 19th Century catname> Dracula title> bram Stoker author> Hardcover binding> 395 pages> $ 17.95 price> book> Great Expectations title> Charles Dickens Author> mass marketpaperback binding> 639 piece> $ 6.95 price> book> Perciva l Keene title> Frederick marryat author> trade paperback binding> 425 pages> $ 12.89 price> book> Treasure Island Title> <
Author> Robert Louis Stevenson Author> Trade Paperback binding> 283 pages> $ 11.85 price> book> wuthering heights title> Emily Bronte author> Hardcover binding> 424 pages> $ 12.95 price> book> category> inventory> List 8-12.17. In the text editor, open the Inventory Hierarchy.htm file created earlier in this chapter. (You can find it in the book CD and list 8-6.)
18. Change the SRC property of the web data island, so that it is connected to the new XML file you just established. That is to say, put it from
xml>
Change to:
xml>
19. To reflect that you will set the new file name, the annotation of the web start part from
change:
20. Save the new file instruction using the text editor to store the modified web page as the InventoryHierarchy Valid.htm file. Listing 8-13 shows a complete HTML page. (You can find it in the Inventory Hierarchyvalid.htm file with the book CD.)
Inventory hierarchy valid.htm ---------------------------------
Inventory of classic english literature title> head> Classic English LITERATURE TH> THEAD> span> td> Tr> Author th> Binding th> Pages TH> Price TH> span> td> span> td> span> td> span> td> span> td> tr> table> td> tr> < / Table> body> html> List 8-13.21. This page is turned on in Internet Explorer 5. It looks like this:
http://jyan.w148.4everdns.com/lycos/xml/images/8-13.gif
22. If the file does not appear, the file must be an error in the correctness or validity of the format. To find out the error, use the validity of the validity of the XML file in Chapter 9 to check the Script. Connect HTML elements to XML properties
As of now, the XML file exemplary you have seen so far does not include the property. Although you can connect to an element that contains attributes, it is connected to the attribute itself, but attributes make the data link more complicated. When you use the data link, the property is in nature is processed as a child element. With the Record element, this processing method makes the access properties easier (or ignore only it). For example, the following book elements include a list of instock properties: The Adventures of Huckleberry Finn title> Mark Twain author> mass market paperback < /BINDINGS (PAGES )298< Priced $ 5.49 book>
This record will be processed, like the instock attribute is a field belonging to the Book, and the value of instock is the content of the field. That is, Book will be seen to have the following structure:
Yes Instock> The Adventures of Huckleberry Finn title> Mark Twain author> mass market paperback binding> 298 pages> $ 5.49 price> book>
So you can use ordinary data link tips to access the value of the property. For example, the following SPAN elements are connected to the attribute and display the value of the attribute:
span>
(This example assumes that the XML file is connected to the web page through a Data Island named DSoinventory.) However, think about it, add the property to the field elements in the XML file -, for example, add the property to the Author field, such as the following example Show:
The Adventures of HuckleBerry Finn title> Mark Twain author> mass market paperback binding> 298 pages> $ 5.49 price> book>
In the data link, the Author element will be interpreted as this:
1835 born> Mark TWAIN author>
As a result, DSO will store the element in a nest-like type, rather than in a field. (Memolive Fields can only contain character data, and no sub-elements.) Therefore, the recordset will become a class-type recordset, not a simple normal recordset, and you must use a nest form to display The nest information inside, as this chapter is introduced in this chapter . However, you need more things, so that you can display attributes of character data (Mark TWAIN) with neo-recorded properties: DSO uses special name $ text to refer to all character data in the element, not to use the attribute value. The way. Therefore, IE5 will explain the Author element to this: 1835 born> <$ text> Mark TWAIN $ text> author>
You can use $ TEXT as a field name to link the table's bar to the contents of Author element character data. Listing 8-14 contains an HTML web page that shows all techniques described in this section. (You can find it in the Inventory Attribute.htm file with the book CD.) This web page shows the XML file: Inven-Tory Valid.xml (you can find the file in the list 5-1 in the book CD).
Inventory Attribute.htm ---------------------------
book inventory title> head> xml> book inventory h2> Author th> Binding TH> Pages TH> < TH> Price TH> IN stock? Th> < TD> span> td> tr> table> td> span> td> span> td> tr> table> td> < TD> span> td> span> td> Span> td> span> td> tr> table> body> html> list 8-14. Below is Internet Explorer 5 Show list 8-14 looks like:
Http://jyan.w148.4everdns.com/lycos/xml/images/8-14.gif
In this web page, the last line of the external table is simply connected to the SAPN element by simply connecting the INSTOCK attribute of the BOOK, showing the contents of the instock attribute:
span> td> Because the author child element of the BOOK element contains an attribute (Born), this property is treated as a nest, not a field, so The web page is the content of the properties using the nest form:
span> td> Span> td> tr> table> td>
Special Name $ TEXT Refer to all text within the Author element, but does not contain attribute values. This text is composed of author name (for example, Mark TWAIN). Note that because the Title element in the Book can include a subtitle, which is also considered a nest record, not a field, and must also use a nest form to display:
span> td> tr> table> TD>
Here, $ text is used to display all of the recorded character data. (There is no way to display only the text of the title instead of the subtitle.) Use Script and DSO this chapter to make a summary of a more complex Script sample. This Script operates with DSO to operate with the records of the associated XML file. This example Script uses the method of the Recordset object of the DSO to search for books in the inventory big.xml file. (You can find this file with the list 8-3.) Used to search for technology with the XML file, only the XML file consisting of simple records is appropriate. (For information on the simple record set, see this chapter. This chapter uses the individual HTML tables to display simple record sets.)
prompt-----
You will see more Script files in Chapter 19. Script in this chapter uses a completely different program object (XML file object model), allowing you to use any type of XML file, not just those XML files constructed with record set. Listing 8-15 Generate an HTML web page containing example Script. You can find it in the Inventory Find.htm file in the book CD.
Inventory Find.htm ---------------------
book find < / Title> head> xml> Find A Book h2> title text: "; return;} DSoinVentory.Recordset .moveFirst (); ResultHTML = ""; while (! dsoInventory.recordset.EOF) {titleString = dsoInventory.recordset ( "TITLE") value;. if (. TitleString.toUpperCase () indexOf (SearchString)> = 0) ResultHTML = "" DSOINVENTORY.Recordset ("Title" " i>," "" DSoinventory.Recordset ("Author") " b>," DSoinventory. Recordset ("Binding") "," DSOINVENTORY.Recordset ("Pages") "Pages," DSOINVENTORY.Recordset ("Price") " "; dsoinventory.Recordset.Movenext ();} If (resulthtml == ")") Resu LTDIV.INNNERHTML = ""; Elseresultdiv.innerhtml = Resulthtml;} script> body> html> list 8-15. This HTML page shows the INPUT element of the text type, letting Enter the text of a group to search for:
This page also shows a button element that is "Search": "; return;} dsoInventory.recordset.moveFirst (); ResultHTML =" "; while (! dsoInventory.recordset.EOF) {titleString = dsoInventory.recordset (" TITLE ") value;. if (TitleString.toUpperCase () .indexof (SearchString)> = 0) Resulthtml = "" DSOINVENTORY.Recordset ("Title" " i>," "" DSOINVENTORY.Recordset ("author" ) " B>," DSOINVENTORY.Recordset ("Binding") ", DSOINVENTORY.Recordset (" Pages ") " Pages, " DSOINVENTORY.Recordset (" Price ") "; DSOINVENTORY.Recordset.movenext ();} if (resulthtml ==") Resultdiv.innerHTML = ""; elseresultdiv.innerhtml = Resulthtml;} script>
Tip ------ JScript is a Microsoft version of the JavaScript program language. (In the Script block of the example, the language property provides the name of the general program language.) You will be able to click on the website http://msdn.microsoft.com/Workshop/c-frame.htm#/workshop/languages/ Jscript / handling.asp is found in http://msdn.microsoft.com/ scripting / default/default.htm, finds JScript complete information, including guidelines made by beginners. These two websites are provided by MSDN. The Findbooks in the Findbooks are started with the current input input INPUT element (its ID SearchText), followed by using JScript Version TouPpercase to convert text into capital letters. (FindBooks convert all the words into larger, making the search "There is no case in size.)
SearchString = SearchText.Value.touppercase ();
If the user does not enter anything in the input element, the function will display an error message and exit execution:
IF (SearchString == "") {resultdiv.innerhtml = ""; Return;
Resultdiv is the ID of the DIV element at the bottom of the web, responsible for displaying the search results. Specifying text (which can contain HTML volumes) for divines will result in DIV display (and execute it HTML tag). The letter will then make the first XML file a current record, using the RecordSet.MoveFirst method you have seen before:
DSoinVentory.Recordset.movefirst ();
Next it will set the html string variable used to store the search result (Resulthtml) to set a blank:
Resulthtml = "";
Now FindBooks will enter the loop to browse all records in the XML file. When the end of the file is reached, it uses the recordset.eof property to stop the loop, and use RecordSet.Movenext to move in each new record:
While (! dsoinventory.recordset.eof) {Titlestring = DSOINVENTORY.Recordset ("Title"). Value; IF (Titlestring.touppercase (). Indexof (SearchString)> = 0) ResultHtml = "" DSoinventory. Recordset ("Title" " i>," "" DSOINVENTORY.Recordset ("Author") " b>," DSOINVENTORY.Recordset ("Binding") "," DSOINVENTORY.Recordset ("Pages") "Pages," DSOINVENTORY.Recordset ("Price") "
"; dsoinventory.recordset.movenext ();} The loop will first get the current recorded title field. value:
Titlestring = DSOINVENTORY.Recordset ("Title"). Value;
The expression on the right side is a speed diak method for the field of the Fields property of the Recordset object. Here is a complete approach:
Titlestring = DSOINVENTORY.RecordSet.fields ("Title"). Value;
The Fields property contains a collection of all fields that are currently recorded. You can access a specific field by placing the name of the field in the parameter (eg, "Title"), and you can get the content of the field with a string type by an additional value attribute.
The loop then uses the JScript Function INDEXOF to determine whether the current record title contains the text to search. If you find the text you want to search, the program in the IF command will put the text in the Resulthtml string with the necessary HTML volume label to display the current record:
IF (Titlestring.touppercase (). Indexof (SearchString)> = 0) ResultHtml = "" DSoinVentory.Recordset ("Title" i>, " " " DSoinventory. Recordset ("Author") " b>," DSOINVENTORY.Recordset ("Binding") "," DSOINVENTORY.Recordset ("Pages") "Pages," DSOINVENTORY.Recordset ("Price" ) "
";
One, the cycle ends, the function will attach the HTML volume label containing the search result to the INNERHTML attribute of the DIV element, this element is located in the body element used to display the search result web page (the Div element recognition code to resultDIV) :
If (resulthtml == ") Resultdiv.innerhtml =" "; elseResultdiv.innerhtml = Resulthtml; DIV element will immediately perform HTML volume label and display the results.
转载请注明原文地址:https://www.9cbs.com/read-92717.html