When we compile ASP code, we all know that we can use post or get to get form data. How can we directly obtain data on other pages? This requires the help of the XMLHTTP protocol. XMLHTTP is part of xmldom technology.
The following code is a simple example. We use XMLHTTP technology to retrieve the code on the first page of http://www.codetoad.com/site in XML format and output it on the page.
<%
Dim objxmlhttp, XML
Set xml = server. Createobject ("Microsoft. XMLHTTP ")
XML. Open "get", "http://www.codetoad.com/", false
'Pull the data from the web page
XML. Send
Response. Write "here's the HTML we now have in our XML Object"
Response. Write "<br>"
Response. Write "<XMP>"
Response. write XML. responsetext
Response. Write "</XMP>"
Response. Write "<br>"
Response. Write "Now here's how the page looks: <br>"
Response. write XML. responsetext
Set xml = nothing
%>
Next is another instance.
<%
Dim objhttp, objxml, objxsl
Set objhttp = server. Createobject ("Microsoft. XMLHTTP ")
Objhttp. Open "get", "http://p.moreover.com/cgi-local/page? C = pop % 20 music % 20 reviews & O = xml ", false
Objhttp. Send
Set objxml = objhttp. responsexml
Set objxsl = server. Createobject ("Microsoft. xmldom ")
Objxsl. async = false
Objxsl. Load (server. mappath ("style. XSL "))
If (objxsl. parseerror. errorcode = 0) then
Response. Write (objxml. transformnode (objxsl ))
Else
Response. Write "error:" & objxsl. parseerror. Reason & "url:" & objxsl. url
End if
Set objhttp = nothing
Set objxml = nothing
Set objxsl = nothing
%>
Style. XSL:
<XSL: stylesheet xmlns: XSL = "http://www.w3.org/TR/WD-xsl">
<XSL: template match = "/">
<HTML>
<Head>
<Title> moreover... </title>
</Head>
<Body bgcolor = "ffffff">
<Div align = "center">
<Table bgcolor = "ffffff" border = "0" cellpadding = "4" cellspacing = "0" width = "100%">
<XSL: For-each select = "moreovernews/article">
<Tr valign = "Middle">
<TD align = "Left" bgcolor = "ffffff">
<XSL: attribute name = "href">
<XSL: value-of select = "url"/>
</XSL: attribute>
<XSL: attribute name = "target">
_ Blank
</XSL: attribute>
<XSL: value-of select = "headline_text"/>
<XSL: attribute name = "href">
<XSL: value-of select = "document_url"/>
</XSL: attribute>
<XSL: attribute name = "target">
_ Blank
</XSL: attribute>
<XSL: value-of select = "Source"/>
<XSL: attribute name = "href">
<XSL: value-of select = "access_registration"/>
</XSL: attribute>
<XSL: attribute name = "target">
_ Blank
</XSL: attribute>
<XSL: value-of select = "access_status"/>
<XSL: value-of select = "harvest_time"/> GMT
</TD>
</Tr>
</XSL: For-each>
</Table>
</Div>
</Body>
</Html>
</XSL: Template>
</XSL: stylesheet>
Author's blog:Http://blog.csdn.net/qieyj/