How to Use XML DSO to Embed Data from XML File into your HTML Pages

The XML DSO (XML Data Source Object) is an ActiveX control. This is built into the browser so that you can use this ActiveX control to embed data from an XML file in to your html web pages.

By using this control you can create dynamic web pages that extract from the external XML file. It is possible to write your own administration pages that can change the data on the XML file. With this you can change the content on your web page without going through the tedious process of doing the changes in your HTML file uploading them through FTP programs.

To use this XML DSO, you have to initialize the XML-DSO object using the <object> tag. This XML-DSO also has a unique CLASSID that also has to be given in the <object> tag. The following is the tag that is to be used in your web page,

<OBJECT ID="GiveSomeID" CLASSID="CLSID:550dda30-0541-11d2-9ca9-0060b0ec3d39"> </OBJECT>

By using this object tag you can extract data from an external file or you can use the data that is embedded in the html file itself in XML format.

Let us take a look on how to extract data from an external XML file and embed it into your html pages using the XML-DSO object. Consider an XML file (external.xml) given below which is the external file that will be used for our example.

<?xml version="1.0" ?>

To embed the data from the above xml file you have to use JavaScript to load that external file while the web page loads. The JavaScript function can be something like this:

<script language="JavaScript">
function loadexternalfile() {
var xmlDso=myXML.XMLDocument;

Include the above code in the <head> section of your web page. The complete code for the html page that includes the XML DSO and the above JavaScript is given below:

<title>Using XML DSO to extract data from external XML file</title>
<script language="JavaScript">
function loadexternalfile() {
var xmlDso=dataXML.XMLDocument;
<body bgcolor="#FFFFFF" onLoad="loadexternalfile()">
<object id="dataXML" CLASSID="clsid:550dda30-0541-11d2-9ca9-
<table datasrc="#dataXML" border="1">
<th>Book Name</th>
<td><div datafld="bookname"></div></td>
<td><div datafld="author"></div></td>

In the above code we are using the <div> tag with the attribute datafld to specify the XML tag that contains the data that is to be displayed in the web page. With the above code the data in the XML file is displayed in two rows since there are two items in the external.xml file. Note that the attribute datasrc of the <table> is set to “#dataXML” which is the id of the XML DSO object used in the code.

Similarly you can use the XML-DSO object to create web pages that need to display very little content from an external XML file. This is one of the easiest ways to display XML data in your web page. Try this!


SetApp - 100 Apps for everything you ever wanted to do on Mac

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.


Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.



FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.



Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.



Add to My Yahoo!

Visit XML Training Material Guide Homepage



“Amazon and the Amazon logo are trademarks of, Inc. or its affiliates.”

Copyright - © 2004 - 2019 - All Rights Reserved.