求助:在一个JSP中写的XML 如何在JS中读出其中的值??并写到一个DIV中。
<%@ page contentType= "text/html; charset=GBK " %>
<%@ page import= "webclicnt.dto.* " %>
<%//该JSP文件名为:mag.jsp。这个XML是动态的,在JS中使用了setInterval定时读取。
MessageDto dto=new MessageDto();
dto= flag.get();//这是从数据库中取值的方法。已经写好的
out.println( " <?xml version= '1.0 ' encoding= 'ISO-8859-1 ' ?> ");
out.println( " <message> ");
out.println( " <adminID> "+dto.getAdminID()+ " </adminID> ");
out.println( " <messageDate> "+dto.getMessage_Date()+ " </messageDate> ");
out.println( " <send> "+dto.getSend()+ " </send> ");
out.println( " </message> ");
%>
------解决方案--------------------function read(){
var XMLMag=GetResult( "mag.jsp ");
alert( "fe ");
var admin=XMLMag.getElementsByTagName( "adminID ");
var messageDate=XMLMag.getElementsByTagName( "messageDate ");
var message=XMLMag.getElementsByTagName( "send ");
document.getElementById( "message ").innerHTML+=admin;//message为DIV的ID
document.getElementById( "message ").innerHTML+=messageDate;
document.getElementById( "message ").innerHTML+=message;
//================继续执行,而且你使用异步不多好?你用同步页面冻结了
setInterval( "read() ",3000);
}