Microsoft HomeproductssearchsupportshopWrite Us   Microsoft Home
Magazine
 |  Community
 |  Workshop
 |  Tools & Samples
 |  Training
 |  Site Info

Workshop  |  XML (Extensible Markup Language)

XML Data Islands


There is an increasing need to be able to embed "islands" of data inside HTML pages. In Microsoft® Internet Explorer 5, these "data islands" can be written in Extensible Markup Language (XML).

This article describes the syntax used for embedding these data islands within a page, and details the object model exposed by the browser to enable them to be used. This method of embedding XML in HTML follows the note published by the W3C as the XML in HTML Meeting Report Non-MS link. The W3C expects to evolve the HTML specification to include the capability of embedding XML in HTML documents.

Embedding an XML Data Island into an HTML Page

An XML data island can be embedded using one of two methods:

Using the XML Tag Within the HTML Document

This syntax is valid for Internet Explorer 5.

There are two syntactically correct ways of using the XML tag within the HTML document:

The XML element is present in the HTML Document Object Model. It is in the all collection and is seen by the browser as just a regular node. The XML data within the XML element can then be accessed by calling the XMLDocument property on the XML element.

The XMLDocument property returns the root node of the XML within the XML element or the root node of the XML referenced by the value of the SRC attribute. From this root, the XML data island can be navigated using the XML document object model. The following function returns the data from the data island with the ID of "XMLID".

function returnXMLData(){
  return document.all("XMLID").XMLDocument.nodeValue;
  }

The XML element can also be referenced by ID alone. For example, the following function has the identical functionality as the previous example.

function returnXMLData(){
  return XMLID.documentElement.text;
  }

Note that because the XMLDocument property was not used, the documentElement property will need to be called to retrieve the root element of the XML.

Overloading the HTML SCRIPT Tag

This syntax has been deprecated and is intended only for down-level cases.

There are three syntactically correct ways of overloading the SCRIPT tag:

The following HTML fragment illustrates how to embed data by overloading the SCRIPT tag.

<SCRIPT ID=XMLID LANGUAGE="XML">
  <XMLDATA>
    <DATA>TEXT</DATA>
  </XMLDATA>
</SCRIPT>

The SCRIPT element is present in the HTML page's object model (it is in the all collection and is seen by the browser as a regular script node). The XML data within the SCRIPT tags can be accessed by calling the XMLDocument property on the SCRIPT object.

The following script accesses the XML data island in the above HTML fragment and returns the name of the root node of the XML data island.

function returnIslandRootName(){
  var islandRoot = document.all.("SCRIPT").XMLDocument;
  return islandRoot.nodeName;
  }

Does this content meet your programming needs? Write us!

Back to topBack to top

© 1998 Microsoft Corporation. All rights reserved. Terms of use.

 

Magazine Home
Ask Jane
DHTML Dude
Extreme XML
For Starters
More or Hess
Servin' It Up
Site Lights
Web Men Talking
Member Community Home
Benefits: Freebies & Discounts
Benefits: Promote Your Site
Benefits: Connect with Your Peers
Benefits at a Glance
Online Special-Interest Groups
Your Membership
SBN Stores
Join Now
Workshop Home
Essentials
Content & Component Delivery
Component Development
Data Access & Databases
Design
DHTML, HTML & CSS
Extensible Markup Language (XML)
Languages & Development Tools
Messaging & Collaboration
Networking, Protocols & Data Formats
Reusing Browser Technology
Security & Cryptography
Server Technologies
Streaming & Interactive Media
Web Content Management
Workshop Index
Tools & Samples Home
Tools
Samples, Headers, Libs
Images
Sounds
Style Sheets
Web Fonts
Training Home
SBN Live Seminars
SBN Live Chats
Courses
Peer Support
CD-ROM Training
Books & Training Kits
Certification
SBN Home
New to SBN?
What's New on SBN
Site Map
Site Search
Glossary
Write Us
About This Site