Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Displaying XML Data Islands with JavaScript-5 : Page 5




Building the Right Environment to Support AI, Machine Learning and Deep Learning

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.



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