www.webdeveloper.com
Results 1 to 6 of 6

Thread: Strings and requests

  1. #1

    Strings and requests

    Code:
     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.

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    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.
    Code:
    URI = Mid(Request.ServerVariables("URL"), 0, 10)
    Regards.

  3. #3
    Ah thanks, I just figured there would be a substring method.

    Now I'm getting another problem, I have the code:
    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?

  4. #4
    Anyone?

  5. #5
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    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.

  6. #6
    Ah that was enough to help me!
    "page[URI = " & URI & "]"
    should have been
    "page[URI = '" & URI & "']"

    Thanks for all your help!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles