Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


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

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>.

 
<HTML>
<HEAD>
<TITLE>XML Data Island Demo</TITLE>
</HEAD>
<BODY>
<XML ID="Employees">
<?xml version="1.0" ?>
<Employees>
	<Employee Code="1234" Name="Deepak Pant"/>
	<Employee Code="1234" Name="Meenakshi Pant"/>
	<Employee Code="1234" Name="Pragati Pant"/>
</Employees>
</XML>
<TABLE DATASRC="#EMPLOYEES">
<TR>
<TD><DIV DATAFLD="Code"></DIV></TD>
<TD><DIV DATAFLD="Name"></DIV></TD>
</TR>
</TABLE>
</BODY>
</HTML>

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.

 

 

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