How to apply XML data 1 in Web design

Source: Internet
Author: User
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 an XML data source object and is an ActiveX control that allows you to hold data between XML files and HTML pages. 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 apply the <OBJECT> tag. 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:

<Object id = 'someid' CLASSID = 'clsid: 550dda30-0541-11d2-9ca9-0060b0ec3d39 '> </OBJECT>

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, use the <XML> tag to include an XML data Island. Next, assign it an ID, xmldb -- for future application. Data is actually extracted using HTML tags: <ALT>, <SPAN>, <DIV>, and so on. The <SPAN> flag is applied to the code in Code List 1. 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. Therefore, the first <SPAN> extracts the name, and the second <SPAN> extracts the gender.

Code List 1:

<! -- Example1.htm -->
<Html>
<Head>
<Title> XML DSO-example1.htm </title>
</Head>
<Body bgcolor = '# ffff'>
<Xml id = 'xmldb'>
<Db>
<Member>
<Name> Premshree Pillai <name>
<***> Male </***>
</Member>
<Member>
<Name> Vinod </name>
<***> Male </***>
</Member>
</Db>
</Xml>

<Span datasrc = '# xmldb' Dataworks = 'name' </span>
<Br>
<Span datasrc = '# xmldb' Dataworks =' *** '> </span>

</Body>
</Html>

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 <name> and <***> tags in the XML data Island. With this method, you can only extract the first instance in these tags. The code application <TABLE> Mark in Code List 2 extracts all instances:

The output will be:
Name Sex
Premshree Pillai male
Vinod male

In code list 2, the <TABLE> tag application <TD> tag <DIV> inside the tag to extract data. The table will automatically repeat each instance of the <member> (<name> and <***> parent tag.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.