An Alternative Using XML Data Islands
The XML data island is created with the
XML tag. The navigation mechanism is different to that normally used. We would usually expect to build a tree of nodes using ID values assigned as HTML tag attributes. This XML navigation technique uses tag names for navigation and is a lot more powerful.
Here, is an example of a block of XML in the middle of a HTML document:
<XML ID='myBlock'> <METADATA> <OWNER>Wrox</OWNER> <DATATYPE>Example</DATATYPE> <ABSTRACT>This is an example block of text.</ABSTRACT> </METADATA> </XML>
Individual nodes in that so-called data island can be accessed through this
XMLDocument property. The object returned by this property responds to the
selectSingleNode() method. The argument to this is the slash-separated path to
the node within the document you are looking for. The slash-separated values are the XML
tagnames used to construct the document.
In this example, they all begin with the string "
since the document only contains one layer inside that, all nodes can be reached with the
Given that our XML block has an
ID value of "
this line of script code should yield a reference to an object that encapsulates the
Having accessed the DOM node you want, its content can be examined by looking at its
The example code illustrates this concept as it might be assembled together in a simple page:
That lets us have some very convenient access to textual data, but this is only
available in Windows-based versions of IE 5+. We can still accomplish largely the same effect
DIV blocks. We can at least build some structure and give them unique
Here is an example of how we can accomplish this. It is amazingly simple, which also makes it a very attractive option.
Save this fragment of script in a file called
var myData1 = "String one"; var myData2 = "String two"; var myData3 = "String three";
Now we can include that file using a
<SCRIPT SRC=""> tag:
The really neat thing about this approach, is that it factors the ticker code and the data into separate files, and the data in the included file can be rendered from a publishing system quite independently of the ticker software.
Created: November 8, 2001
Revised: November 8, 2001