当前位置: 首页 > 图文教程 > 网络编程 > ASP > XML DOM介绍和例子(二)

ASP
asp下检查表中是否存在某个字段(列)函数
ASP批量更新代码
asp飞飞无限级分类v1.0 Asp+sql+存储过程+ajax提供下载
比较详细的ASP rs.open语句详细说明
可以应用到马克斯电影站生成Rss Feed的代码
ASP 无限级分类实现
从数据库中读取记录横向排列
ASP动态级联菜单实现代码
网上用的比较多的asp级联菜单效果代码
ASP提高数据显示效率-缓存探幽
asp经常被忽视的一种死循环
关于Asp代码与页面的分离模板技术
用GetString提高ASP的速度
用cookies实现闪电登录论坛方法
一个不太让人讨厌的自动弹出窗口
asp格式化日期时间格式的代码
ASP变量加变量实现代码
asp向数据库插入数据的方法rs
asp上传带显示的代码
asp防止垃圾留言代码

ASP 中的 XML DOM介绍和例子(二)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 80 ::
收藏到网摘: n/a

  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