欢迎来到福编程网,本站提供各种互联网专业知识!

建立XMLHttpRequest对象

发布时间:2006-07-28 作者: 来源:转载
utl.js复制代码代码如下:functioncreateXmlTree(node,indent){if(node==null)return"";varstr="";switch(node.nodeType){case1://Elementstr+="";str+=">";varcs=node.childNodes;for(vari=0;i"break;case4://CDATAstr=""+node.nodeValue+"]

utl.js
复制代码 代码如下:functioncreateXmlTree(node,indent){

if(node==null)
return"";
varstr="";

switch(node.nodeType){
case1://Element
str+="<"+node.nodeName+"";

varattrs=node.attributes;
for(vari=0;istr+=createXmlAttribute(attrs[i]);

if(!node.hasChildNodes())
returnstr+"/>

";

str+=">

";

varcs=node.childNodes;
for(vari=0;istr+=createXmlTree(cs[i],indent+3);

str+=""+node.nodeName+">

";
break;

case9://Document
varcs=node.childNodes;
for(vari=0;istr+=createXmlTree(cs[i],indent);
break;

case3://Text
if(!/^s*$/.test(node.nodeValue))
str+=""+node.nodeValue+"

";
break;

case7://ProcessInstruction
str+="

varattrs=node.attributes;
for(vari=0;istr+=createXmlAttribute(attrs[i]);

str+="?>

"
break;

case4://CDATA
str=""+
node.nodeValue+
"]"+"]>

";
break;

case8://Comment
str="

";
break;

case10:
str="if(node.publicId){
str+="PUBLIC""+node.publicId+""";
if(node.systemId)
str+="""+node.systemId+""";
}
elseif(node.systemId){
str+="SYSTEM""+node.systemId+""";
}
str+=">

";

//TODO:HandlecustomDOCTYPEdeclarations(ELEMENT,ATTRIBUTE,ENTITY)

break;

default:
//alert(node.nodeType+"n"+node.nodeValue);
inspect(node);
}

returnstr;
}

functioninspect(obj){
varstr="";
for(varkinobj)
str+="obj."+k+"="+obj[k]+"n";
window.alert(str);
}

functioncreateXmlAttribute(a){
return""+a.nodeName+"=""+a.nodeValue+""";
}
复制代码 代码如下:

Ajax test


rel=stylesheet>




复制代码 代码如下:
HTML {
BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px
}
BODY {
BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px
}
BODY {
BACKGROUND: buttonface; FONT: Message-Box
}
FORM {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px
}
FIELDSET FIELDSET {
MARGIN: 5px
}
BUTTON {
MARGIN-LEFT: 5px
}
TEXTAREA {
WIDTH: 100%; HEIGHT: 200px
}
#out {
BORDER-RIGHT: threeddarkshadow 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: threeddarkshadow 1px solid; MARGIN-TOP: 5px; PADDING-LEFT: 3px; BACKGROUND: white; PADDING-BOTTOM: 3px; BORDER-LEFT: threeddarkshadow 1px solid; COLOR: black; PADDING-TOP: 3px; BORDER-BOTTOM: threeddarkshadow 1px solid; FONT-FAMILY: Verdana
}
#srcTextContainer {
DISPLAY: none
}
.element {
PADDING-LEFT: 16px; COLOR: blue
}
.elementname {
COLOR: darkred
}
.attribname {
COLOR: red
}
.attribvalue {
COLOR: blue
}
.text {
PADDING-LEFT: 16px; COLOR: windowtext
}
.cdata-content {
DISPLAY: block; PADDING-LEFT: 16px; BORDER-LEFT: gray 1px solid; COLOR: windowtext; FONT-FAMILY: Courier New; WHITE-SPACE: pre
}
.comment {
PADDING-LEFT: 16px; COLOR: blue
}
.doctype {
PADDING-LEFT: 16px; COLOR: blue
}
.comment-content {
DISPLAY: block; COLOR: gray; FONT-FAMILY: Courier New; WHITE-SPACE: pre
}
#XMLDebug {
BORDER-RIGHT: #000 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #000 1px solid; MARGIN-TOP: 6px; PADDING-LEFT: 4px; FONT-SIZE: 12px; BACKGROUND: #fff; PADDING-BOTTOM: 4px; OVERFLOW: auto; BORDER-LEFT: #000 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: #000 1px solid; HEIGHT: 400px
}

相关推荐