|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








