Skip navigation

Internet Explorer XML Data Islands

You probably know that almost all of an HTML page's content affects the way in which a browser renders an HTML page. Data islands, a feature of Internet Explorer (IE) 5.0 and higher, are XML documents embedded within an HTML page. As such, they are blocks of data that are insulated from the rest of the page; they can exist within the body of an HTML page but don't affect the appearance of the page. If you think about this idea for a while, you soon realize that it isn't as trivial as it might seem.

A sequence of markup delimiters, which—in most cases—are unknown tags for a Web browser, form an XML document. Usually, Web browsers ignore unknown tags but slipstream all the text found between the opening and the closing tag in the main body of the page. For example, the following HTML page

<html>
<body>
<mytag>Hello, World</mytag>
This is XML UPDATE
</body>
</html>

produces the following output in both IE 5.0+ and Netscape Communicator:

Hello, World This is XML UPDATE

Neither browser recognizes the <mytag> tag, but both insert the inner text in the body.

In IE 5.0+, the <xml> root element tag identifies a data island:

<xml>
Well-formed XML document here
</xml>

This tag has a special meaning to the browser, and its content is automatically invisible. Assigning an ID to the tag lets you programmatically retrieve and process the XML code later.

<xml id="myXmlDoc">. . . </xml>

Given the above declaration, the browser automatically instantiates an XML Document Object Model (XMLDOM) object named myXmlDoc. You can embed XML code with an inline syntax (as above) or by linking to an external URL:

<xml id="myXmlDoc" src="url"> </xml>

Embedding XML code within an HTML page has many applications. For example, data islands are a great way to carry data from a server-side database to a local page, making the browser responsible for formatting and rendering the data. If the user requests a different view, a different sort order, or a filter, you don't need to go back to the server to obtain the same data with a slightly different layout.

More generally, data islands are a way to embed external blocks of data that have no impact on the final page rendering. Although they might not affect the page rendering, data islands aren't invisible to the rest of the page. In fact, data islands let you script against the XML document. The advantage is that you don't need to load the XML document through script or through the <OBJECT> tag. Data islands are particularly helpful if you generate them on the server through an Active Server Pages (ASP) script. And by referencing an ASP page, you have another chance to control the data island creation process.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish