[Home] [By Thread] [By Date] [Recent Entries]
Hi,
I just begin in XSL-server side and I want to search in particular xml element in a xml file and I know that I have more than one element that correspond to ... I do tests with the selectSingleNode and I have good result except that I only have the first element of the matching pattern ... In fact, I do other tests with the selectNodes method (...method who return all the element ...) but with no success ... Can somebody help me, That will be nice... Eric Here is the asp file: <%@ LANGUAGE = JScript %> <% // Error formatting function: function reportError(where, error) { Response.Write("<font face=Arial><B>Error loading '" + where + "'</B></font> <BLOCKQUOTE><XMP>" + error.reason + "</XMP></BLOCKQUOTE>"); } // Load the XML var xmlDoc = Server.CreateObject("Microsoft.XMLDOM"); xmlDoc.async = false; var weed = Request.QueryString("weed"); var fileName = "Xml/PlantTypes.xml"; xmlDoc.load(Server.MapPath(fileName)); if (xmlDoc.parseError.errorCode != 0) { reportError(fileName, xmlDoc.parseError); } else { // Load the stylesheet var style = Server.CreateObject("Microsoft.XMLDOM"); style.async = false; var fileName = "Xsl/weed.xsl"; style.load(Server.MapPath(fileName)); if (style.parseError.errorCode != 0) { reportError(fileName, xmlDoc.parseError); } // Process it var pattern = "/SgPlantTypes/SgPlantType[@ID='" + weed + "']"; var node = xmlDoc.documentElement.selectNodes(pattern); var result = node.transformNode(style); Response.Write(result); } %> and here is the xsl file: <?xml version="1.0"?> <HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <HEAD> </HEAD> <BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:12pt; background-color:#FDF5B5"> padding-top:3pt; padding-bottom:3pt;">MAUVAISE HERBE:</SPAN> </td> <xsl:for-each select="node()"> <DIV STYLE="margin-left:26pt; margin-right:1pt; font-size:10pt; <xsl:value-of select="@NAME"/> </xsl:for-each> </BODY> </HTML>
|

Cart



