Jump to content

asp code to dispaly the correct data


prichardson

Recommended Posts

HelloI am trying to do an xml feed with the use of xslt.... but before you switch off - the reason why I have put in a post in asp forum because it has some asp code which I was really hoping someone could tell me if this is correct or tell me which bit of the code is wrong or if all of it is wrong.The asp code comes into play with what i am trying to do when it uploads the xml and xsl pages and to define and use the parameter with the MSXML processor.I probably should give you a quick insight to what i am trying to do - in a bigger picture to help you see where this asp code fits into the bigger picture. Well basically an estate agency gets his data from an externa company regarding the properties. There is going to be a form that allows web users to select options to search under - taking location as an example - if a user selects 'Chiswick' under location. Then all the properties from the xml sheet that have Chiswick in the location tags will display. I have put the xml and xsl together with the help of boen_robot and here below is my asp code - please tell me what needs to be changed to allow the data to be displayed with the parameter 'location = Chiswick'?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%><?xml version="1.0" encoding="ISO-8859-1"?><%dim strServerPathdim strlocationstrServerPath	= Request.ServerVariables("APPL_PHYSICAL_PATH")strlocation 	= Request.QueryString("location")%><% Response.ContentType = "text/html" %><%set xml = Server.CreateObject("Microsoft.XMLDOM")xml.ValidateOnParse = Truexml.async = falsexml.load(Server.MapPath("properties.xml"))set xsl = Server.CreateObject("Microsoft.XMLDOM")xsl.ValidateOnParse = Truexsl.async = falsexsl.load(Server.MapPath("properties.xsl"))Dim strResultDim templatesDim transformertemplates = Server.CreateObject("MSML2.XSLTemplate")templates.stylesheet = objXSL.documentElementtransformer = templates.createProcessor()transformer.input = objXMLtransformer.addParameter("location", Request.QueryString("location"), "")strResult = transformer.transform()%>

Cheers

Link to comment
Share on other sites

Can anyone give me an alternative to this line

transformer.addParameter("location", Request.QueryString("location"), "")

or how to modify it, because at the moment i am getting this error:"Cannot use parentheses when calling a Sub" - I believe the problem is the bit after the Querystring - ("location").ANy help really appreciatedCheers

Link to comment
Share on other sites

Thank you - justsomeguy for your help.I have got it to work on my local server. The next step is for me to access the external company's xml data. For me to do that I have to 'call' the xml application which is: hxxp:/xxx.net/xxx/xxx/aspasia_search.xml?upw=xxx . This was my code i had for it to find the xml application on my local server:

strServerPath = Request.ServerVariables("APPL_PHYSICAL_PATH")

I am not sure what command i should put in front of the URL to get the aspasia url. for example

strServerPath = Request.ServerVariables("hxxp:/xxx.net/xxx/xxx/")

That does not seem quite right, because the "Request.ServerVariables" does not look right command. Because the page is one one url and is asking for the xml document which is on an external (another) url. So what command code should i put?this is the rest of the code that i am using - as you can see i have the actual bit of the xml document - aspasia_search.xml

strlocation 	= Request.QueryString("lo")Set xmldoc = Server.CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")xmldoc.async = falsexmldoc.load(Server.mapPath("aspasia_search.xml"))

or should i put that line as:

xmldoc.load(Server.mapPath("hxxp:/xxx.net/xxx/xxx/aspasia_search.xml?upw=xxx"))

What do you think?

Link to comment
Share on other sites

Request.ServerVariables is a collection containing some information that the server has avialable to it, such as various paths, IP addresses, protocol information, etc. They are the variables that the server is making available to the ASP script, it's not a command.Server.MapPath is a function that maps a filename to the current directory. If you have a script at this location:c:\inetpub\wwwroot\asp\files\test.aspAnd inside that script you do this:path = Server.MapPath("test.txt")The path variable will now contain "c:\inetpub\wwwroot\asp\files\test.txt". Server.MapPath provides the full path to the current folder, that's all that does. Using Server.MapPath with an HTTP path does not make sense. So this line:xmldoc.load(Server.mapPath("aspasia_search.xml"))will load a file called aspasia_search.xml which is inside the same folder as the ASP script that is running the code. If you want to load a file over HTTP, don't use Server.MapPath, just send the full URL to the load function.You can learn more about the request and server objects here:http://www.w3schools.com/asp/asp_ref_request.asphttp://www.w3schools.com/asp/asp_ref_server.asp

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...