Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Displaying XML Data Islands with JavaScript-5 : Page 5


advertisement
Create The Navigation Mechanism
At this point, the Employee Directory isn't very useful. You can see only the first record of the data island. You can think of "flat" XML documents like this example, where the elements translate to rows and columns, as the equivalent of database tables. In fact, you can treat them as a set of scrollable records. Therefore, adding a navigation system is also rather simple. First, create an external JavaScript file in your favorite text editor, and then add the following code and save the file in the same directory as data.xml:

function first(){ data.recordset.moveFirst(); } function previous(){ if(data.recordset.absoluteposition>1) data.recordset.movePrevious(); } function next(){ if(data.recordset.absoluteposition < data.recordset.recordcount) data.recordset.moveNext(); } function last(){ data.recordset.moveLast(); }

The four functions above represent movement through the records exposed by the data island. They encapsulate simple ADO record set commands and are virtually self-explanatory. Note that you refer to the data island in script by the same name as that specified in the id attribute of the <xml> element. By referring to the recordset sub-object, you can make use of all of the commands of an ADO record set. Now that's handy!


Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date