aspではXMLHTTPを利用して他のページからデータを取得するコードです。

2612 ワード

XMLHTTPを利用する 他のページからデータを取得してASPコードを作成する時、皆さんはpostまたはgetを通してフォームのデータを得ることができると知っていますが、私達はどのように直接他のページのデータを獲得しますか?これはxmlhttpの協議を借ります。xmlhttpはxmldom技術の一部です。下記のコードは簡単な例です。xmlhttp技術を利用して、http://www.xxxx.com/サイトトップのコードをxml形式で完全に取得し、ページに出力します。<%ディム ObjXMLHTTP、 xmlセット xml = Server.reate Object(「Microsoft.XMLHTTP」)xml.Open "GET" "http://www.codetoad.com/「 False Pull the ダタ from the web page xml.Send Resonse.write "ヘレ. the html we now すばらしい in our xml Object「Resonse.write」 "


「Resonse.Write」 "「Response.Write xml.reponse Text Resonse.Write "「Response.write "


「Resonse.write」 " ナウ here ホ the page look s:

“Resonse.Write” xml.reponseText Set xml = Nothing%>次は別の例です。 objHTTP , ObjXML , objXSLセット objHTTP = Server.reate Object(「Microsoft.XMLHTTP」)objHTTP.open "GET" "http://p.moreover.com/cgi-local/page?c=Pop%20music%20reviews&o=xml「 false objHTTP.send set ObjXML = objHTTP.reponseXML set objXSL=Server.reate Object(microsoff.xmldom)objXSL.async=false objXSL.load(Server.MapPath(「style.xsl」)if (objXSL.parseError.errorCode = 0) then Resonse.Write(objXML.tranformnode)else Resonse.Write "Err: " & objXSL.parseError.reason & " URL:" & ObjXSL.url end ifセット objHTTP = Nothing Set ObjXML = Nothing Set ObjXSL = Nothing%>style.xsl:moreover… BGCOLOR=「ffff」<DIV ALIGN=「センター」 BGCOLOR=「ffffff」 BORDER="0" CELLPADDING="4" CELLSPACING="0" WIDT H=「100%」 name=「TARGET」blank GMT