泸州泸县太伏学校血案,呜呜呜444爱她com图片,红杏砸墙
5. parseerror对象
打开xml文档时,xml parser产生错误代码,并存在parseerror对象中,包括错误代码、错误文本和错误行号,等信
息。
6.文件错误
下面的例子将试图装载一个不存在的文件,然后产生相应的错误代码:
var xmldoc = new activexobject("microsoft.xmldom")
xmldoc.async="false"
xmldoc.load("ksdjf.xml")
document.write("<br>error code: ")
document.write(xmldoc.parseerror.errorcode)
document.write("<br>error reason: ")
document.write(xmldoc.parseerror.reason)
document.write("<br>error line: ")
document.write(xmldoc.parseerror.line)
7.xml错误
下面使用不正确的格式装载xml文档,
var xmldoc = new activexobject("microsoft.xmldom")
xmldoc.async="false"
xmldoc.load("note_error.xml")
document.write("<br>error code: ")
document.write(xmldoc.parseerror.errorcode)
document.write("<br>error reason: ")
document.write(xmldoc.parseerror.reason)
document.write("<br>error line: ")
document.write(xmldoc.parseerror.line)
8. parseerror属性
属性描述:
errorcode 返回长整型错误代码
reason 返回字符串型错误原因
line 返回长整型错误行号
linepos 返回长整型错误行号位置
srctext 返回字符串型产生错误原因
url 返回url装载文档指针
filepos 返回长整型错误文件位置
9.遍历节点树
一种通用的析取xml文档的方法是遍历节点树和它的元素值。下面是使用vbscript写的遍历节点树的程序代码:
set xmldoc=createobject("microsoft.xmldom")
xmldoc.async="false"
xmldoc.load("note.xml")
for each x in xmldoc.documentelement.childnodes
document.write(x.nodename)
document.write(": ")
document.write(x.text)
next
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
网友评论