XML is a standard extension language and a standard for Web programming in the future. asp is a widely used Web Programming Language Is it possible for the two of them to work together? Here we will provide you with an example of simple interaction between ASP and XML. For example, we will not be ugly here for the limited length and knowledge of XML and XSL. The following is a few things. the content of the file used.
Testxsl. XSL:
CopyCode The Code is as follows: <? 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: Copy codeThe Code is as follows: <? 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
Copy code The Code is as follows: <%
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") is used to load
XML file containing data. XSL. Load (server. mappath ("testxsl. XSL") is used to load XSL containing data rules.
File, and use XML. transformnode (XSL) to use the preceding rules in the XML file.