Subject:Trouble with param Author:Ed Butcher Date:12 Mar 2007 11:27 AM
Hi
I'm trying to use a parameter to select one recipe from a file containing several hundred recipes. The XML looks like this:
<recipe sLove="loveeveryday" name="BLT Special">
<sTitle>BLT Special</sTitle>
<sLove>loveeveryday</sLove>
<sImage>BLT Special</sImage>
<sSubTitle>Makes 2 sandwiches</sSubTitle>
<ingredients>
<ingredient>4 slices soft white bread</ingredient>
<ingredient>4 rashers smoked, rindless back bacon</ingredient>
<ingredient>2 pork and herb sausages</ingredient>
<ingredient>Butter, softened (or favourite spread)</ingredient>
<ingredient>2 crisp lettuce leaves, shredded</ingredient>
<ingredient>3 small vine tomatoes, sliced</ingredient>
<ingredient>2 tbsp mayonnaise or tomato relish</ingredient>
</ingredients>
<methods>
<method>1. Cook the bacon and sausages under a pre-heated grill, turning, until cooked. Slice the sausages diagonally.</method>
<method>2. Spread the slices of bread with butter.Arrange the lettuce and tomato slices on two slices of bread. Top with sausage slices, mayonnaise or tomato relish and bacon.</method>
<method>3. Place the remaining bread slices on top, cut in half and serve immediately.</method>
</methods>
</recipe>
The problem I'm having is trying to filter out just one recipe. I'm calling the page like this: recipes.asp?recipetitle=BLT Special
Subject:Trouble with param Author:Ed Butcher Date:14 Mar 2007 10:49 AM
I've changed the way I was approaching this: now I'm using SelectSingleNode in my ASP.
This is what I have...
<%
Dim xmlSource, xslSource, strOutput, recipetitle, objNode
recipetitle = Request.QueryString("recipetitle")
Set xmlSource=Server.CreateObject("Microsoft.XMLDOM")
Set xslSource=Server.CreateObject("Microsoft.XMLDOM")
xmlSource.async=false
xslSource.async=false
if xmlSource.parseError.errorcode<>0 then
response.write xmlSource.parseError.errorcode
else
Set objNode = xmlSource.SelectSingleNode("recipes/recipe[@name='" & recipetitle & "']")
set xmlSource = nothing
set xslSource = nothing
set objNode = nothing
%>
This is correctly displaying the right bit of the XML file, although my XSL isn't working properly - it's not displaying all the elements I expect it to.