- 114 -
Most of the examples in this section are HTML documents that have JavaScript and XML
documents embedded within them. These HTML examples can be pasted into a file and
loaded with Internet Explorer 5 to view the intended result. In
Chapter 6
, we talk about
using the XML DOM usage within different environments including Microsoft’s Internet
Explorer 5. This section provides an introduction to help you follow the examples in this
chapter.
XML documents embedded within HTML pages/documents are called
data islands
. Let’s
say that we’d like to create a data island using the following XML document.
This is my XML document.
The above simple XML document is embedded into a data island by using a new,
reserved HTML tag called (you guessed it) “
”. Here’s how to use it:
This is my XML document.
An
id
is provided so the script can reference the XML document. The
id
becomes
especially useful when the HTML document contains more than one XML data island.
The above script is embedded with an HTML document and shows how to make use of
the data island. xmlID is the Document node and, in this case, is assigned to a variable
called documentNode. For those unfamiliar with JavaScript, JavaScript is not a strongly
typed language. var allows you to create a variable, and you can then assign any kind of
variable or object to it. In this case, we assigned a Document object to documentNode.
The same syntax would be used if we were to assign a integer value to a variable.