Home > Article > Backend Development > Let Asp interact with XML
XML is a standard extension language and the standard for future Web programming. ASP is one of the most popular web programming languages. Can they be combined to play a role? Tofu is here to provide you with a very simple example about XML and
<?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>
<?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>
<% 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)) %>
set xml = Server.CreateObject("Microsoft.XMLDOM") set xsl = Server.CreateObject("Microsoft.XMLDOM")
Contains Data xml file, xsl.load(server.mappath("testXSL.xsl")) is used to load the xsl
file containing data rules, and finally use xml.transformNode(xsl) to use the previous rules in the XML file
The above is the content that allows Asp to interact with XML. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!