Results 1 to 4 of 4

Thread: Xmlhttp

  1. #1
    Join Date
    Mar 2003
    Location
    Memphis, TN, USA
    Posts
    61

    Unanswered: Xmlhttp

    Hi there !

    How one can fetch the some part of the page not the whole page using xmlhttp ? If anyone knows then please explain it with example or guided me to direct help.

    With Thanks !
    SQLBOY

  2. #2
    Join Date
    Mar 2003
    Location
    Atlanta, GA
    Posts
    191
    Not sure if this is what you're looking for or not.

    I've modified the code so it's more generic, but here's my solution for getting product registration data from a database I keep on my site.
    The request for data from my server.....

    xO is previously defined as the customers order ID

    Code:
    SendString = "xO=" & xO
    set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
    objHTTP.open "POST", "<A href="http://www.mysite.com/Xcheck.asp",false">http://www.mysite.com/Xcheck.asp",false
    objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
    objHttp.Send SendString
    xStatus = objHttp.Status
    xResult = objHttp.ResponseText		 
    '
    If xStatus = "200" then 'communication was Good
    If InStr(xResult,"License")>0 then
    tL = xResult
    Else
    tL = "INVALID"
    xMessage = ""
    If InStr(xResult,"ERROR")>0 then
    xMessage = xResult
    End If
    End If
    ' some code to update my database
    Else
    tL = "ERROR"
    xMessage = "Can't communicate with Licensing Server"
    End If
    Set objHTTP = Nothing
    And the code on my server is....

    Code:
    Response.ContentType = "text/xml"
    xL="INVALID"
    If Len(Request("xO"))=8 then
    	 Set Q1 = Server.CreateObject("ADODB.Connection")
    	 Q1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\mysite\data\Db1.mdb" 
    	 Set rsQ = Server.CreateObject("ADODB.Recordset")
    	 rsQ.Open "SELECT TOP 1 * FROM VMtable",Q1
    	 If rsQ.EOF then 
    		xMessage="ERROR: OrderID Not in Our Database!"
    	 Else 
    		xL = Request("xO")
    	 End If
    Else
    	 xMessage="ERROR: OrderID Invalid!"
    End If
     
    If xL = "INVALID" then
    strXML = "<?xml version=""1.0"" encoding=""iso-8859-1""?>" & _
    	"<response><error>1</error><message>" & xMessage & "</message></response>"
    Response.write strXML
    Response.End
    Else
    strXML = "<?xml version=""1.0"" encoding=""iso-8859-1""?>" & _
    	"<response><error>0</error><message>License=" & xL & "</message></response>"
    Response.write strXML
    '
    ' then I have some code to update my database...
    End If
    rsQ.close : Set rsQ=nothing : Q1.close : Set Q1=Nothing
    The actual code is more complex, but this should give you the basic idea.

    Tim
    Tim

  3. #3
    Join Date
    Mar 2003
    Location
    Memphis, TN, USA
    Posts
    61

    Thanks Mr.Wizard aka Tim

    Thanks Tim for the lovely writeup.

    You're true. I am not looking exactly what you mentioned in your reply but you're writeup gave me a good idea about it.

    I am just new born kid and have a good understanding of prg language. I am trying to make dynamic online stock index report before my school gets open..( Hope, you are smart enough to catch my point)..

    Thanks for your time and consideration.

    sqlboy

  4. #4
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    The problem you may encounter with screenscraping is that most HTML sites are not properly formatted to be parsed by an XML parser. So you either need to get the source data from an XML feed, or hope the site is well formed.
    That which does not kill me postpones the inevitable.

Posting Permissions

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