Thursday, January 3, 2008

Binding XML to HTML

Binding XML to HTML is used to display XML on an HTML page. The XML binding technique described on this page relies on proprietary Microsoft-addons which may only work for Microsoft Internet Explorer 5.0 and above. This binding is based on the Microsoft Data Source Object (DSO) programming model which allows scripts or data binding to be used to display an XML document from HTML

To bind an XML file to an HTML file:

1,Use a line similar to the following:


2,Use the SPAN element or TABLE element to bind the XML file to the elements at the proper location

Here's the HTML code:












ItemManufacturerModelCost



Here's the XML file, parts.xml.






Motherboard
ASUS
P3B-F
123.00


Video Card
ATI
All-in-Wonder Pro
160.00


Sound Card
Creative Labs
Sound Blaster Live
80.00


19 inch Monitor
LG Electronics
995E
290.00



Here's the DTD:



type (computerautoairplane) #IMPLIED>





Notice in the implementation, below, that the attributes specified by the XML file are overridden by the default attributes in HTML. None of the items are displayed using the color or font sizes specified by the CSS file that is referenced in the XML file, so that reference in the XML file is not effective.
Here's how it looks. If you can't see the contents of the table, your browser probably does not support XML or the Microsoft Data Source Object (DSO) programming model.

No comments: