日期:2014-05-16 浏览次数:20478 次
(一)IE浏览器:
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
//创建两条处理指令
var newPI=xmlDoc.createProcessingInstruction("xml","version=\"1.0\" encoding=\"utf-8\"");
xmlDoc.appendChild(newPI);
//创建根元素
var documentElement=xmlDoc.createElement("req");
xmlDoc.appendChild(documentElement);
//创建CDATA
//var newCD=xmlDoc.createCDATASection("This is a CDATASection node");
//xmlDoc.documentElement.appendChild(newCD);
//创建元素invoice,其子元素customer,再为customer加上属性,
var chatRoom=xmlDoc.createElement("chatRoom");
var id=xmlDoc.createElement("id");
var cname=xmlDoc.createElement("cname");
var ctype=xmlDoc.createElement("ctype");
var maxUsers=xmlDoc.createElement("maxUsers");
var welcomes=xmlDoc.createElement("welcomes");
var description=xmlDoc.createElement("description");
var status=xmlDoc.createElement("status");
var startTime=xmlDoc.createElement("startTime");
var closeTime=xmlDoc.createElement("closeTime");
var createTime=xmlDoc.createElement("createTime");
chatRoom.appendChild(id);
chatRoom.appendChild(cname);
chatRoom.appendChild(ctype);
chatRoom.appendChild(maxUsers);
chatRoom.appendChild(welcomes);