如何用javascript解析xml
解决方案 »
- 严重: Exception starting filter springSecurityFilterChain 的问题
- hibernate+srping oracle clob 在插入超过一定字符后报错
- plsql developer连接服务器上的oracle10g出错。挺急的,非常感谢。
- 如何使用jaxb向xml中追加数据元素
- 学习J2EE技术从哪入手.
- struts标签问题
- 单点登陆和LDAP是什么关系
- jboss下EJB的运行错误???
- 请问谁能把HelloWorld的EJB的例子给我一份
- 关于对象映射,并模糊查询
- java.lang.NoSuchMethodException: Action does not contain specified method
- java已经给了服务器,怎么聊天?
//设置xml
var xml = "<chats><chat>";
xml+="<touser>"+document.all.toUser.value+"</touser>";
xml+="<content>"+document.all.content.value+"</content>";
xml+="</chat></chats>"
alert(xml);最后可以回调:
function responseResult(){
if (xmlHttp.readyState==4){
if (xmlHttp.status==200){
//alert(xmlHttp.responseText);
//得到xml对象
var httpXML = xmlHttp.responseXML;
//取聊天集合
var chats = httpXML.getElementsByTagName("chat");
for(var i=0;i<chats.length;i++){
alert(chats[i].nodeName);
alert(chats[i].childNodes.length);
}
//alert(chats.length);
//document.all.chatHistory.innerHTML+="<div>"+xmlHttp.responseText+"</div>";
}else if(xmlHttp.status==404){
alert("404");
}else if (xmlHttp.status==500){
alert("500");
}
}
}
var doc = dom.loadXML(xmlStr);
doc里面就有相关的方法了,方法名与Java中的org.w3c.dom中的类似