你可以这样

Code Snippet

<body>

<script type="text/javascript">
var xmlHttp;
function createXMLHttpRequest(){
if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
else if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}

function startRequest(){
createXMLHttpRequest();
try{
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("GET", "http://www.baidu.com", true);
xmlHttp.setRequestHeader("Content-Type","text/html; charset=utf-8");
xmlHttp.send(null);
}catch(exception){
alert("您要访问的资源不存在!" + exception);
}
}

function handleStateChange(){
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200 || xmlHttp.status == 0){
// 显示返回结果
var bbb=(xmlHttp.responseText); //--这里面bbb是百度返回的整个页面源代码
document.getElementById("x").innerHTML = bbb
alert(document.getElementById("km").innerHTML);//--我想取百度里面哪个ID为km的标签的数据,如何做呢
}
}
}
startRequest()
</script>

后记:将获取的html代码加载到本页再做处理。

来自微软web技术论坛:http://social.microsoft.com/forums/zh-CN/295/thread/83e41ddc-5f51-48ba-b29b-513c612ea088