一個客戶提供一個股價的信息,要求放在頁面上,顯示一些數據,需要從遠程獲取xml,然后解析寫在網頁上,開始不會覺得很難,其實蠻簡單的,先用javascript寫了一個:
<script language=javascript>
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("
http://****.com/scripts/****.asp?subcode=C22");
nodes = xmlDoc.documentElement.childNodes;
var text = xmlDoc.selectSingleNode("http://last").text
document.write(text);
</script>
http://****.com/scripts/****.asp?subcode=C22 ,是客戶提供的頁面,其實是xml的內容,這里直接調用windows的組件進行讀取,然后調用其中一個selectSingleNode的方法,讀出last字段的內容;
VBscript也寫了一個,其實差不多,不過有一點不同,asp中VB的不能直接讀取遠程xml的內容,很奇怪,不知道是不是由于VB的限制:
dim XMLMorntekDocument
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET","
http://****com/scripts/******.asp?subcode=C22",False http.send
Set XMLMorntekDocument=Server.CreateObject("Microsoft.XMLDOM")
XMLMorntekDocument.Async=False
XMLMorntekDocument.ValidateOnParse=False
XMLMorntekDocument.Load(http.ResponseXML)
price = XMLMorntekDocument.selectSingleNode("http://last").text
response.write price
Set http=Nothing
Set XMLMorntekDocument=Nothing
這里先用XMLHTTP的方法,get到xml文件,然后再解析。
posted @
2005-04-16 14:03 Stephen 閱讀(290) |
評論 (0) |
編輯 收藏
import java.io.*;
import java.util.regex.*;
public class test{
public static void main(String[] args){
try{
String s = "";
while(!s.equals("q")){
System.out.print("input:");
DataInputStream in = new DataInputStream(new BufferedInputStream(System.in));
s = in.readLine();
System.out.println("your input is :"+s);
String check = "^([a-z0-9A-Z]+[-|\\._]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
Pattern regex = Pattern.compile(check);
Matcher matcher = regex.matcher(s);
boolean isMatched = matcher.matches();
if(isMatched){
System.out.println("it's a email");
}else{
System.out.println("it's not a email");
}
}
}catch(Exception e){
System.out.println("error"+e.getMessage());
}
}
}
posted @
2005-04-16 14:02 Stephen 閱讀(728) |
評論 (0) |
編輯 收藏
摘要: 1. ASP與Access數據庫連接:
dim conn,mdbfile mdbfile=server.mappath("數據庫名稱.mdb") set conn=server.createobject("adodb.connection") 'conn.open "driver={microsoft ac...
閱讀全文
posted @
2005-04-16 09:01 Stephen 閱讀(225) |
評論 (0) |
編輯 收藏
我可以定義自己css??
posted @
2005-04-04 12:04 Stephen 閱讀(393) |
評論 (3) |
編輯 收藏
厭煩了csdn的錯誤,搬個新房子,風格還不錯~I like it.
posted @
2005-04-04 11:50 Stephen 閱讀(156) |
評論 (0) |
編輯 收藏