Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web
Expertise: Beginner
Jun 15, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Displaying an XML Data Island in an HTML Table

The <XML> tag can be used to create an XML data island. XML data islands are XML- data referenced or included in an HTML page. The XML data can be part of the HTML document, or it can stay in an external data file.

The ID attribute given with the <XML> tag is used to reference the data island. You can format and display the data in the XML data island by using HTML tags that can accept data source tags. Basically, the whole idea is to bind the HTML to the data.

Here is an example that displays the XML items tagged with <Employee>.

<TITLE>XML Data Island Demo</TITLE>
<XML ID="Employees">
<?xml version="1.0" ?>
	<Employee Code="1234" Name="Deepak Pant"/>
	<Employee Code="1234" Name="Meenakshi Pant"/>
	<Employee Code="1234" Name="Pragati Pant"/>

The <TABLE> tag uses the DATASRC attribute to reference the in-line XML. The DATASRC refers to the ID attribute used to identify the XML preceded by a pound sign (#).

Since the TD element cannot be bound to data, we are using the DIV element. The DIV element allows the DATAFLD attribute to refer to the XML element that is placed in the cell of the table. In this case, it's DATAFLD="Code" for the "Code" attribute of the <Employee> XML element. As the XML is read, additional rows are created for each element tagged with the <Employee> tag.

Deepak Pant
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date