Data Islands

Data Islands


In Microsoft® Internet Explorer 5.0, you can the use <XML> element to create a data island. Data islands are XML data referenced or included in an HTML page. The XML data can be included within the HTML or it can be in an external file.

Using the <XML> element allows you to avoid using script; if the user has disabled scripting for security reasons, the object tag version will not work because script is required to initialize the XML.

Inline XML is enclosed within the <XML> and </XML> tags, as shown in the following example.

<XML ID="xmlData">
<height unit="foot">10</height>
<height unit="foot">4</height>

External XML uses the SRC attribute on the <XML> tag to reference an external file. The SRC attribute can refer to a local file or specify a URL. By using URLs that point to external servers, data can be integrated from several sources. The following code uses the SRC attribute with a local file.

<XML ID="xmlData" SRC="xmlData.xml"></XML>

The file xmlData.xml contains the XML. The SRC attribute can refer to a URL as well, as in the following example.

<XML ID="xmlData" SRC="">

The ID attribute of the <XML> element is used to reference the data island. By using HTML tags that can accept data source tags (binding the HTML to the data), you can format and display the data in the XML data island. The following example displays the XML items tagged with <meeting>.

<XML ID="xmlMeetings">
<?xml version="1.0" ?>
<table datasrc="#xmlMeetings">
<td><div datafld="date"></div></td>
<td><div datafld="time"></div></td>
<td><div datafld="location"></div></td>

The <table> element uses the datasrc attribute to reference the inline XML. The datasrc refers to the ID attribute used to identify the XML, preceded by a pound sign (#). The TD element cannot be bound to data, so a tag that binds to data must be used. In this case, it is the <DIV> element. The <DIV> element also allows the datafld attribute to refer to the XML element to place in this cell of the table. In this case, it is datafld="date" for the <date> XML element.

As the XML is read, additional rows are created for each element tagged with the <meeting> tag.

© 2016 Microsoft