XML with Data Source Object

What is XML Data Source Object?

XML Data Source Object is a Microsoft Active X object built into the web browser so we can use ActiveX control to extract data from the XML code embedded directly in the HTML file and the external XML file using data binding into HTML web pages.

Data islands

  • XML code is embedded in an HTML document to create data islands.
  • The file should be saved with .html or .htm extension.
Data islands are created with two methods:

1. Explicit method: Embedding data directly.

<XML ID=“xmlID”>
     <!-- XML data-->

2. Implicit method: Embedding XML data with reference to external XML file.
<XML ID=“xmlID” SRC=“filename.xml”></XML>

  • The DSO object is implicitly created when we use a XML data island.
  • To extract data from external data file use the HTML tags.
  • <IMG>, <LABLE>, <TABLE>
  • Two attributes are very important along with html tags.
  • a) DATASRC: Specifies the source of data.
    b) DATAFLD: Specifies the field from where the data is to be displayed.

Example : Write a program to display content in table using XML-DSO

     <xml id="xml">
     <table datasrc="#xml">
               <td><div datafld="name"></div></td>
               <td><div datafld="sex"></div></td>
               <name>BOB </name>

bob xml dso

XML-DSO object is used to load external XML document.

The steps to do this are as follows:
  • Create and initialize XML-DSO object.
  • Syntax:
  • Load the external XML file in HTML page using the XMLDSO. We have to use Javascript in the <HEAD> section of HTML page.
  • Extract data from loaded XML file through HTML tags using DATASRC and DATAFLD.