XML Data Islands in IE 5.0


HTML Document with XML Data Island

<html>
<head>
<title>
DOM Data Island Example
</title>
</head>
<body>
<XML ID="catalog">
<catalog>
<book>
<author>Simon St.Laurent</author>
<title>XML Elements of Style</title>
<pubyear>2000</pubyear>
<publisher>McGraw-Hill</publisher>
<isbn>0-07-212220-X</isbn>
<price>$29.99</price>
</book>
<book>
<author>Simon St.Laurent</author>
<title>XML: A Primer, 2nd Ed.</title>
<pubyear>1999</pubyear>
<publisher>IDG Books</publisher>
<isbn>0-7645-3310-X</isbn>
<price>$19.99</price>
</book>
<book>
<author>Simon St.Laurent</author>
<title>Building XML Applications</title>
<pubyear>1999</pubyear>
<publisher>McGraw-Hill</publisher>
<isbn>0-07-134116-1</isbn>
<price>$49.99</price>
</book>
</catalog>
</XML>
<table>
<thead>
<tr>
  <th>Author</th>
  <th>Title</th>
  <th>Pub Date</th>
  <th>Publisher</th>
  <th>ISBN</th>
  <th>Price</th>
</tr>
</thead>
<tbody>
<script>
nodeCatalog=document.all("catalog").XMLDocument;
booksNodeList=nodeCatalog.getElementsByTagName("book");
entries=booksNodeList.length;
for (i=0; i<entries; i++) {
  bookNode=booksNodeList.item(i);

  document.write("<tr>");
  childNode=bookNode.firstChild;
  for (j=0; j<6; j++) {
    document.write("<td>");
    valueNode=childNode.firstChild;
    document.write(valueNode.nodeValue);
    document.write("</td>");
    childNode=childNode.nextSibling;
  }
document.write("</tr>");
}
</script>
</tbody>
</table>
</body>
</html>

Test it

<Origin Page   TOC

Copyright 2000 Simon St.Laurent