You are on page 1of 1

XML Tutorial - Embedding XML in HTML

Page 1 of 2

Overview

In this chapter you will learn : o How to embed XML into HTML? o What are the various ways to get XML data source? o What is Data Binding?
XML can be used to store data inside HTML documents. XML data can be stored inside HTML pages as "Data Islands". As HTML provides a way to format and display the data, XML stores data inside the HTML documents. The data contained in an XML file is of little value unless it can be displayed, and HTML files are used for that purpose.

The simple way to insert XML code into an HTML file is to use the <xml> tag. The XML tag informs, the browser that the contents are to be parsed and interpreted using the XML parser. Like most other HTML tags, the <xml> tag has attributes. The most important attribute is the ID, which provides for the unique naming of the code. The contents of the XML tag come from one of two sources : inline XML code or an imported XML file.

If the code appears in the current location , it's said to be inline.

Example Embedding XML code inside an HTML File. <html> <xml Id = msg> <message> <to> Visitors </to> <from> Author </from> <Subject> XML Code Islands </Subject> <body> In this example, XML code is embedded inside HTML code </body> </message> </xml> </html>

The efficient way is to create a file and import it. You can easily do so by using the SRC attribute of the XML tag.

Syntax <xml Id = msg SRC = "example1.xml"> </xml>

Data Binding
Data binding involves mapping, synchronizing, and moving data from a data source, usually on a remote server, to an end user's local system where the user can manipulate the data. Using data binding means that after a remote server transmits data, the user can perform some minor data manipulations on their own local system. The remote server does not have to perform all the data manipulations nor repeatedly transmit variations of the same data.

Data binding involves moving data from a data source to a local system, and then manipulating the data, such as, searching, sorting, and filtering, it on the local system. When you bind data in this way, you do not have to request that the remote server manipulate the data and then retransmit the results; you can perform some data manipulation locally. In data binding, the data source provides the data, and the appropriate applications retrieve and synchronize the data and present it on the terminal screen. If the data changes, the applications are written so they can alter their presentation to reflect those changes. Data binding is used to reduce traffic on the network and to reduce the work of the Web server, especially for minor data manipulations. Binding data also separates the task of maintaining data from the tasks of developing and maintaining binding and presentation programs.

You might also like