Home > Backend Development > XML/RSS Tutorial > A sample code sharing using XML to interact with Asp

A sample code sharing using XML to interact with Asp

黄舟
Release: 2017-03-25 17:27:26
Original
1518 people have browsed it

XML is a standard extension language and the standard for future Web programming. asp is one of the widely circulated webprogramming languages. Can it be used? What about the two of them joining forces? Tofu is here to provide you with a very simple source example of interaction between Asp and XML. Regarding XML and XSL, due to the limited space and knowledge level, Tofu will not show off here. First, let’s talk about the contents of several files that need to be used.
testXsl.xsl:

<?xml version=&#39;1.0&#39;?> 
<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=&#39;boy&#39;]"> 
<input type="text"> 
<xsl:attribute name="value"> 
<xsl:value-of select="NAME"/> 
</xsl:attribute> 
</input> 
<br/> 
</xsl:when> 
<xsl:otherwise match=".[FG=&#39;girl&#39;]"> 
<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>
Copy after login

testXML.xml:

<?xml version="1.0" encoding="gb2312" ?> 
<PERSONNEL> 
<PERSON> 
<NAME>男性</NAME> 
<FG>boy</FG> 
</PERSON> 
<PERSON> 
<NAME>女性</NAME> 
<FG>girl</FG> 
</PERSON> 
<PERSON> 
<NAME>呵呵,这个可不好说</NAME> 
<FG>donot know</FG> 
</PERSON> 
</PERSONNEL>
Copy after login

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)) 
%>
Copy after login

Contrast this example, let’s mainly talk about the testXML.asp file
set xml = Server.CreateObject("Microsoft.XMLDOM")
set xsl = Server.CreateObject("Microsoft.XMLDOM")
Used to create an instance of xml and xsl respectively, where xml.load(server .mappath("testXML.xml")) is used to load
xml files containing data, xsl.load(server.mappath("testXSL.xsl")) is used to load xsl
files containing data rules, Finally, use xml.transformNode(xsl) to use the previous rules in the XML file.

The above is the detailed content of A sample code sharing using XML to interact with Asp. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template