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.


Making Use of the XML Data Source Object  : Page 2

The XML Data Source Object is an ActiveX control that allows you to manipulate data between XML files and HTML pages. This article will show you the basics of how to extract content from various XML data sources and how to present that data using a little JavaScript.




Application Security Testing: An Integral Part of DevOps

Extract Data Using an XML Data Island
First, include an XML data island by using the <XML> tag. Next, assign it an ID, xmldb—for use later. Data is actually extracted using HTML tags: <ALT>, <SPAN>, <DIV>, etc. The code in Listing 1 uses the <SPAN> tag. The datasrc attribute specifies the ID of the data island from which you want to extract data. The datafld attribute specifies the XML tag from which you want the data. So, the first <SPAN> extracts the name, and the second <SPAN> extracts the gender.

Note that the code does not initialize an XML-DSO object. This is because the use of an XML data island implicitly creates one.

The output should be:

Premshree Pillai male

Note that there are two <name> and <sex> tags in the XML data island. Using this method, you can only extract the first instances of these tags. The code in Listing 2 extracts all instances using the <TABLE> tag:

The output should be:



Premshree Pillai




In Listing 2, the <TABLE> tag extracts data using <DIV> tag within the <TD> tag. The table will automatically iterate through each instance of <member> (the parent of <name> and <sex>).

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