Allow ASP to interact with XML

Source: Internet
Author: User

Allow ASP to interact with XML
Standard, ASP is a widely used Web Programming Language One, can you make them
What is the role of the two partners? Here is a simple example of tofu.
The limited length and knowledge of XML and XSL are not here to be ugly.
The following describes the content of several files to be used.

Testxsl. XSL:

<? XML version = '1. 0'?>
<XSL: stylesheet xmlns: XSL = "http://www.w3.org/TR/WD-xsl">
<XSL: template match = "/">
<HTML>
<Body>
<XSL: For-each select = "personnel/person">
<XSL: Choose>
<XSL: When match = ". [fg = 'boys']">
<Input type = "text">
<XSL: attribute name = "value">
<XSL: value-of select = "name"/>
</XSL: attribute>
</Input>
<Br/>
</XSL: When>
<XSL: otherwise match = ". [fg = 'girl ']">
<Font color = "red"> <li> <XSL: value-of select = "name"/> </LI> </font>
<Br/>
</XSL: otherwise>
<XSL: otherwise>
<Font color = "blue"> <XSL: value-of select = "name"/> </font>
</XSL: otherwise>
</XSL: Choose>

</XSL: For-each>
</Body>
</Html>
</XSL: Template>
</XSL: stylesheet>

Testxml. xml:
<? XML version = "1.0" encoding = "gb2312"?>
<Personnel>
<Person>
<Name> male </Name>
<FG> boy </FG>
</Person>
<Person>
<Name> female </Name>
<FG> girl </FG>
</Person>
<Person>
<Name> well, this is not easy to say </Name>
<FG> donot know </FG>
</Person>
</Personnel>

Testxml. asp

<%
Set xml = server. Createobject ("Microsoft. xmldom ")
XML. async = false
XML. Load (server. mappath ("testxml. xml "))

Set XSL = server. Createobject ("Microsoft. xmldom ")
XSL. async = false
XSL. Load (server. mappath ("testxsl. XSL "))

Response. Write (XML. transformnode (XSL ))

%>

Let's take a look at the testxml. asp file.
Set xml = server. Createobject ("Microsoft. xmldom ")
Set XSL = server. Createobject ("Microsoft. xmldom ")
Used to create an XML and XSL instance respectively. xml. Load (server. mappath

("Testxml. xml") used to load
XML file containing data. XSL. Load (server. mappath ("testxsl. XSL") is used to load

XSL of data rules
File, and use XML. transformnode (XSL) to use the preceding rules in the XML file.
Run the following demo:
Http://www.asp888.net/study/testXML.asp
Download the entire file in: http://www.asp888.net/download/asp/xml/testXML.zip

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.