Coding, HTML/XHTML/HTML5

XML Data Island

An XML data island is XML data embedded into a Microsoft introduced a special <xml> tag in Internet Explorer 4. This <xml> tag is used to create a XML data island that can hold XML to be used within the document. While querying a database, it is possible to bring more data than required from database and store it in XML data island. You may then allow the user to retrieve new information form the data island without going back to the server.

The following example explains the concept: Let us assume, we have the following XML file.

<?xml version = "1.0" encoding="ISO-8859-1"?>
<directory>
<employee>
 <name>James Fernandex</name>
 <title> Controller of Examination</title>
 <phone>033-33434459</phone>
 <email>jfernandez@democomp.com</email>
</employee>
</directory>
</xml>

Next this XML document can be referenced in a HTML file by specifying it’s URL using the <xml> tag:

 <xml id="staff" src="staff.xml"></xml>

Once the XML file is included in the document, then it is possible to bind the XML elements to HTML tags. A very common requirement is to bind the XML data to a table.
Following code binds the staff.xml file to a table and converts the data into a html table.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/1999/xhtml">
<head>
<title>Employee Details</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
<body>
<xml id="myisland" src="staff.xml"></xml>
<h1 align="center">Code Rewind Employee Directory</h1>
<hr/>
<table width="100%" datasrc="#myisland">
<thead>
 <tr>
 <th>Name</th>
 <th>Title</th>
 <th>Phone</th>
 </tr>
</thead>
<tbody>
 <tr>
          <td><span datafld="name"></span></td>
          <td><span datafld="title"></span></td>
         <td><span datafld="phone"></span></td>
         <td><span datafld="email"></span></td>
 </tr>
</tbody>
</table>
</body>
</html>

Buy VPN