The XML data source object is an ActiveX control that allows you to control data between an XML file and an HTML page. This article will show you how to extract data from various XML data sources and how to use JavaScript to display the data. The XML data source object DSO is
The XML data source object is an ActiveX control that allows you to control data between an XML file and an HTML page. This article will show you how to extract data from various XML data sources and how to use JavaScript to display the data.
The XML data source object DSO is a Microsoft ActiveX control built on versions later than Microsoft IE4. This object promises you to extract an external XML file or content embedded in the HTML file to the HTML page.
You can apply XML-DSO to select content from an external XML file on a Web page, extract XML data from the XML embedded in the Web page, and then apply JavaScript to hold the data. However, it is not recommended to apply this object on the Internet. because DSO can only work in browsers with MSIE 4 or above, this may bring some compatibility titles. Therefore, the application of XML-DSO in the enterprise intranet is very suitable.
Start
To initialize the XML-DSO object, we applyMark. The CLASSID for XML-DSO is:
CLSID: 550dda30-0541-11d2-9ca9-0060b0ec3d39
This ID uniquely identifies XML-DSO. Use the following code to initialize the control on a Web page:
Although most objects need a lot of parameters associated with it, but the XML-DSO does not need any parameters.
Apply an XML data Island to retrieve data
First, through the application Tag contains an XML data Island. Next, assign it an ID, xmldb -- for future application. The data is actually HTML tags :, And so on. The code in Code List 1 has been appliedMark. The datasrc attribute specifies the data island from which you want to extract data. The Dataworks attribute specifies the XML tag of the data you want. So, the firstExtract the name, while the secondExtract gender.
Code List 1:
Reference content is as follows:
XML DSO-example1.htm
Premshree Pillai
<***> Male
Vinod
<***> Male
Note that this code does not initialize a XML-DSO object. This is because an application of XML data Island has been implicitly created. The output should be:
Premshree Pillai
Male
Note that there are two And <***>. With this method, you can only extract the first instance in these tags. Code application in Code List 2
The output will be:
Name Sex
Premshree Pillai male
Vinod male
In code list 2,
Mark to extract all instances:
XML DSO-example2.htm
Premshree Pillai
<***> Male
Vinod
<***> Male
Tag an application
Mark in the tag to extract data. The table will be repeated. ( And <***>. Code List 2: |
Reference content is as follows:
Extract data from external XML files
To apply the XML-DSO to load an external XML file, you must explicitly include this object and apply some JavaScript.
First create a XML-DSO object, application ID myXML. Add the width and height attributeMark, and then set their values to 0. This ensures that XML-DSO objects do not reside in any space on your web page.
Second, use datasrc to create a table like myXML-similar to that in Code List 2. The code application tag (marked in TD) extracts data. the application dataworkflow is used as the information in the first column, and the application URL is used as the second column. Add the SCRIPT tag, because here, the external XML application Java SCRIPT explicitly declares the XML file you want to load.
Set xmlDso to myXML. XMLDocument. MyXML references your created object. Next, load example3.xml using the load () method of the XML-DSO. File example3.xml is connected to the object myXML.
Reference content is as follows:
JavaScript Ticker using XML DSO
Http://someURL.com
Now, study the following HTML page:
Reference content is as follows:
XML DSO-example3.htm