Click to See Complete Forum and Search --> : Strings and requests


IncaWarrior
12-01-2004, 09:01 PM
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
Set objLst = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async = False
xmlDoc.Load (server.mappath("counters.xml"))

URI = Request.ServerVariables("URL").Substring(10)
Set cnode= xmlDoc.documentElement.SelectSingleNode("page[URI = " & URI & "]").childNodes(1).text
cnode.childNodes(1).text = Int32.Parse(cnode.childNodes(1).text)+1
set objXMLDoc = nothing
%>

The idea is that this code takes the header info and increments a value in an xml database that represents the hits for a page. Unfortunately I can't get it to work at all :(. The Substring(10) makes it say "Object required: '..pageurl..'", and it wants more when I tell it to select a node.

buntine
12-01-2004, 10:01 PM
Strings are not objects in classic ASP, therefore, it does not have any methods. Unless your using ASP.NET (hard to tell from this example).

Use the Mid function.

URI = Mid(Request.ServerVariables("URL"), 0, 10)

Regards.

IncaWarrior
12-01-2004, 10:26 PM
Ah thanks, I just figured there would be a substring method.

Now I'm getting another problem, I have the code:

URI = Mid(Request.ServerVariables("URL"),11)
Set cnode= xmlDoc.documentElement.SelectSingleNode("page[URI = " & URI & "]")
cnode.childNodes(1).text = Int32.Parse(cnode.childNodes(1).text)+1

and I get an error "Object required: 'xmlDoc.documentElement.SelectSingleNode(...)'"

Doesn't SelectSingleNode return an object node?

IncaWarrior
12-02-2004, 05:40 PM
Anyone?

buntine
12-02-2004, 05:57 PM
Mayby "page[URI = " & URI & "]" does not generate the name of a node.

Use Response.Write("page[URI = " & URI & "]") and see what it prints out.

Regards.

IncaWarrior
12-02-2004, 06:46 PM
Ah that was enough to help me!
"page[URI = " & URI & "]"
should have been
"page[URI = '" & URI & "']"

Thanks for all your help!