xml| Data | page | page when we write the ASP code, we all know that we can get the data of form forms by post or getting, so how do we get the data directly from other pages? This is going to be through the XMLHTTP agreement. XMLHTTP is part of the XMLDOM technology.
The following code is a very simple example, we use the XMLHTTP technology, the http://www.codetoad.com/site first page of the code in the form of XML fully obtained, and output in 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><BR><BR>"
Response.Write "<xmp>"
Response.Write Xml.responsetext
Response.Write "</xmp>"
Response.Write "<BR><BR><BR>"
Response.Write "Here's how the page looks:<br><br>"
Response.Write Xml.responsetext
Set xml = Nothing
%>
Here is another example
<%
Dim objhttp, Objxml, objxsl
Set objhttp = Server.CreateObject ("Microsoft.XMLHTTP")
Objhttp.open "Get", "Http://p.moreover.com/cgi-local/page?c=Pop%20music%20reviews&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= "/" >
<TITLE>moreover...</TITLE>
<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>
</xsl:template>
</xsl:stylesheet>