Example of an example source code _xml that interacts with XML with ASP

Source: Internet
Author: User
Tags xsl
XML is the standard extensible language, is the standard of the future Web programming, ASP is now widely circulated in one of the Web programming language, can you let them both together to play a role? Tofu here to give you a very simple ASP and XML implementation interaction of an example source example about XML and XSL limited to space and knowledge level tofu is not here shortcoming the following is the first of several documents to be used.
testxsl.xsl:
Copy Code code as follows:

<?xml version= ' 1.0 '?>
<xsl:stylesheet xmlns:xsl= "Http://www.w3.org/TR/WD-xsl";>
<xsl:template match= "/" >
<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>
</xsl:template>
</xsl:stylesheet>

Testxml.xml:
Copy Code code as follows:

<?xml version= "1.0" encoding= "gb2312"?>
<PERSONNEL>
<PERSON>
<NAME> male </NAME>
<FG>boy</FG>
</PERSON>
<PERSON>
<NAME> Women </NAME>
<FG>girl</FG>
</PERSON>
<PERSON>
<NAME> Oh, this is not easy to say </NAME>
<fg>donot know</fg>
</PERSON>
</PERSONNEL>


testxml.asp

Copy Code code 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))
%>

In contrast to this example, we 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 separately, where Xml.load (Server.MapPath ("Testxml.xml") is used to load
The XML file that contains the data, Xsl.load (Server.MapPath ("testxsl.xsl")) to load the XSL containing the data rule
file, which ultimately uses Xml.transformnode (XSL) to use the preceding rule in the XML file.
Related Article

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.