内容简介:用Asp与XML实现交互的一个实例源码XML 是标准扩展语言,是未来Web编程的标准,asp 是现在广为流传的web编程语言之一,能不能让他们两个联合起来发挥作用呢?豆腐在这里给大家提供一个很简单的Asp与XML实现交互的一个实例源例子关于XML和XSL限于篇幅和知识水平豆腐就不在这里献丑了下面首先来说说几个需要用到的文件的内容。
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='boy']">
<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>男性</NAME>
<FG>boy</FG>
</PERSON>
<PERSON>
<NAME>女性</NAME>
<FG>girl</FG>
</PERSON>
<PERSON>
<NAME>呵呵,这个可不好说</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))
%>
对照这个例子,我们主要来讲一下 testXML.asp 文件
set xml = Server.CreateObject("Microsoft.XMLDOM")
set xsl = Server.CreateObject("Microsoft.XMLDOM")
用来分别创建一个xml和xsl的实例,其中xml.load(server.mappath("testXML.xml"))用来加载
包含数据的xml文件,xsl.load(server.mappath("testXSL.xsl"))用来加载包含数据规则的xsl
文件,最终利用xml.transformNode(xsl)将前面的规则使用在XML文件中。
以上所述就是小编给大家介绍的《用Asp与XML实现交互的一个实例源码》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- Kafka 源码解析:网络交互模型
- Hadoop YARN:ApplicationMaster与ResourceManager交互源码解析
- iOS 12 人机交互指南:交互(User Interaction)
- 生活NLP云服务“玩秘”站稳人机交互2.0语音交互场景
- asyncio之子进程交互
- 以太坊交互工具
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Rationality for Mortals
Gerd Gigerenzer / Oxford University Press, USA / 2008-05-02 / USD 65.00
Gerd Gigerenzer's influential work examines the rationality of individuals not from the perspective of logic or probability, but from the point of view of adaptation to the real world of human behavio......一起来看看 《Rationality for Mortals》 这本书的介绍吧!