Subject: selectSingleNode and selectNodes method ... From: Éric Riblair <eriblair@xxxxxxxxxxxx> Date: Mon, 28 Dec 1998 13:08:10 -0500 |
selectSingleNode and selectNodes method ... 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"> <TABLE BORDER="0"> <tr> <td><SPAN STYLE="margin-left:8pt; font-size:11pt; font-weight:bold; padding-top:3pt; padding-bottom:3pt;">MAUVAISE HERBE:</SPAN> </td> </tr> <TR> <TD> <xsl:for-each select="node()"> <DIV STYLE="margin-left:26pt; margin-right:1pt; font-size:10pt; font-weight:bold; padding-top:0pt;"> <xsl:value-of select="@NAME"/> </DIV> </xsl:for-each> </TD> </TR> </TABLE> </BODY> </HTML> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
selectSingleNode and selectNodes me, Éric Riblair | Thread | triple model of layout, Andy Dent |
selectSingleNode and selectNodes me, Éric Riblair | Date | Re: MSIE5b2 compliance with latest , Biron,Paul V |
Month |