XML Data Binding in HTML web page

 

Data binding is a process that allows an Internet user to manipulate Web-page elements using an Internet Explorer Web browser. It employs dynamic HTML and does not require complex scripting or programming. 

Binding XML data in web page
In this article a Web page is used in conjunction with mails.xml to demonstrate Internet Explorer HTML data binding.  Without any scripting, this will pull data from the XML file and display it in the HTML page by using attributes.

 

First create an XML file called mails.xml like so:

 

<?xml version="1.0" encoding="utf-8" ?>

<Mails>

  <Mail>

    <UserID>UserMail1@domain.com</UserID>

    <UserName>User Name 1</UserName>

  </Mail>

  <Mail>

    <UserID>UserMail2@domain.com</UserID>

    <UserName>User Name 2</UserName>

  </Mail>

</Mails>

 

Next create an HTML file called mails.html like so:

 

<html>

<head>

    <title>User Names :: Cherukuri</title>

</head>

<body>

    <xml id="Mails" src="mails.xml" />

    <table datasrc="#Mails">

        <tr>

            <td><strong>Name</strong>:</td>

            <td>

                <div datafld="UserID" /></td>

        </tr>

        <tr>

            <td><strong>Mail</strong>:</td>

            <td>

                <div datafld="UserName" />

            </td>

        </tr>

    </table>

</body>

</html>

 

The mails.html file pulls the data out of your mails.xml file and puts it into your mails.html page using the technology called data binding

The datasrc attribute sets or retrieves the source of the data for data binding from specified file. The dataFld attribute sets or retrieves which field of a given data source, as specified by the datasrc property, to bind to the specified object.