If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Xmlhttp

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-14-04, 00:58
sqlboy sqlboy is offline
Registered User
 
Join Date: Mar 2003
Location: Memphis, TN, USA
Posts: 61
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
Reply With Quote
  #2 (permalink)  
Old 08-14-04, 16:23
MrWizard MrWizard is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 08-15-04, 08:57
sqlboy sqlboy is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 08-15-04, 16:51
Seppuku Seppuku is offline
Useless...
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On