linux社区爱心援助Linux认证系列教程业界动态站务新闻公司招聘网络学院网址大全LPI专题CISCO专题
设为首页
加入收藏
管理团队
JSP  
JAVA  
PERL  
 您的位置:首页 > 开发语言 > ASP >
栏目导栏
  php
  JSP
  ASP
  asp.net
  JAVA
  c/c++/c#
  perl
  JavaScript
  Basic
  Delphi
资料搜索
热门文章
·由HTTP 500 Internal server e
·会员系统“找回密码”的制作方
·ASP实现数字和字母组合并生成图
·简单的asp验证码程序示例
·用ASP制作强大的搜索引擎
·如何让图片自动缩放以适合界面
·如何用foreach遍历页面上所有的
·如何实现站点的RSS输出
·无组件实现文件上传/下载
·ASP如何获取真实IP地址
·asp中如何使用 HTML 表格
·采用XMLHTTP编写一个天气预报的
·80004005错误及其解决方法
·asp中如何调试 ASP 脚本
·asp+ajax打造无刷新新闻评论系
最新文章
·ASP教程:8、ASP内建对象Respo
·ASP教程:7、ASP内建对象Reque
·ASP教程:6、ASP脚本循环语句
·ASP教程:5、ASP脚本变量、函数
·ASP教程:4、ASP脚本基础
·ASP教程:3、ASP基础
·ASP教程:2、ASP简介
·ASP教程:1、Are you ready?
·ASP中使用SQL语句教程
·ASP进度条
·由HTTP 500 Internal server e
·Asp无组件生成缩略图
·ASP 系列函数大全(4)
·ASP 系列函数大全(3)
·ASP 系列函数大全(2)
Google
 
ASP操作XML文件的完整实例
[ 作者:  加入时间:2007-11-20 16:40:16  来自:Linux联盟收集整理 ]
  <% NaGLinux联盟
  '---------------------------------------------------------------- NaGLinux联盟
  '程序简介: 完成asp语言对XML文档中指定节点文本的增加、删除、修改、查看 NaGLinux联盟
  '入口参数: 无 NaGLinux联盟
  '出口参数: 无 NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  '函数名字:ConnectXml() NaGLinux联盟
  '入口参数: filename 需要连接或打开的xml文件名 NaGLinux联盟
  '出口参数: 无 NaGLinux联盟
  '返回值 :ConnectXml=0,XMLMorntekDocument就是一个成功装载XML文档的对象了。 NaGLinux联盟
  ' ConnectXml<>0,则打印错误信息strError NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  dim XMLMorntekDocument NaGLinux联盟
   NaGLinux联盟
  function ConnectXml(filename) NaGLinux联盟
  dim strSourceFile NaGLinux联盟
  strSourceFile = Server.MapPath(filename) NaGLinux联盟
  Set XMLMorntekDocument = Server.CreateObject("Microsoft.XMLDOM") NaGLinux联盟
  XMLMorntekDocument.async = false NaGLinux联盟
  XMLMorntekDocument.load(strSourceFile) NaGLinux联盟
  ConnectXml=XMLMorntekDocument.parseerror.errorcode NaGLinux联盟
  if XMLMorntekDocument.parseerror.errorcode<>0 then NaGLinux联盟
  strError="<h2>error"&XMLMorntekDocument.parseerror.errorcode&"</h2>" NaGLinux联盟
  strError=strError&XMLMorntekDocument.parseerror.reason&"<br>" NaGLinux联盟
  strError=strError&XMLMorntekDocument.parseerror.url&"<br>" NaGLinux联盟
  strError=strError&XMLMorntekDocument.parseerror.line&"<br>" NaGLinux联盟
  strError=strError&XMLMorntekDocument.parseerror.filepos&"<br>" NaGLinux联盟
  strError=strError&XMLMorntekDocument.parseerror.srcText&"<br>" NaGLinux联盟
  response.write strError NaGLinux联盟
  end if NaGLinux联盟
  end function NaGLinux联盟
   NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  '函数名字:CloseXml() NaGLinux联盟
  '入口参数: 无 NaGLinux联盟
  '出口参数: 无 NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  function CloseXml(XMLMorntekDocument) NaGLinux联盟
  if IsObject(XMLMorntekDocument) then NaGLinux联盟
  set XMLMorntekDocument=nothing NaGLinux联盟
  end if NaGLinux联盟
  end function NaGLinux联盟
   NaGLinux联盟
   NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  '函数名字:SelectXmlNodeText(elementname) NaGLinux联盟
  '入口参数: elementname 元素的名字 NaGLinux联盟
  '出口参数: 无 NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  function SelectXmlNodeText(elementname) NaGLinux联盟
   elementname="//"&elementname NaGLinux联盟
   temp=XMLMorntekDocument.selectSingleNode(elementname).text NaGLinux联盟
   selectXmlNodeText= server.htmlencode(temp) NaGLinux联盟
   NaGLinux联盟
  end function NaGLinux联盟
   NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  '函数名字:InsertXmlNodeText(befelementname,elementname,elementtext) NaGLinux联盟
  '入口参数: elementname 插入的元素的名字 NaGLinux联盟
  ' befelementname在此元素的名字前面插入元素 NaGLinux联盟
  ' elementtext 插入的元素的文本 NaGLinux联盟
  '出口参数: 无 NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  function InsertXmlNodeText(befelementname,elementname,elementtext) NaGLinux联盟
  dim befelement,element NaGLinux联盟
  set befelement=XMLMorntekDocument.selectSingleNode("//"&befelementname) NaGLinux联盟
  set element= XMLMorntekDocument.createelement(elementname) NaGLinux联盟
  befelement.insertBefore element,befelement.firstchild NaGLinux联盟
  element.text=elementtext NaGLinux联盟
  end function NaGLinux联盟
   NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  '函数名字:UpdateXmlNodeText(elementname,newelementtext) NaGLinux联盟
  '入口参数: elementname 元素的名字 NaGLinux联盟
  ' newelementtext元素的新文本 NaGLinux联盟
  '出口参数: 无 NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  function UpdateXmlNodeText(elementname,newelementtext) NaGLinux联盟
  dim element NaGLinux联盟
  set element=XMLMorntekDocument.selectSingleNode("//"&elementname) NaGLinux联盟
  element.text=newelementtext NaGLinux联盟
  end function NaGLinux联盟
   NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  '函数名字:DeleteXmlNodeText(elementname) NaGLinux联盟
  '入口参数: elementname 元素的名字 NaGLinux联盟
  '出口参数: 无 NaGLinux联盟
  '------------------------------------------------ NaGLinux联盟
  function DeleteXmlNodeText(elementname) NaGLinux联盟
  XMLMorntekDocument.selectSingleNode("//"&elementname).text ="" NaGLinux联盟
  end function NaGLinux联盟
  %> NaGLinux联盟
   NaGLinux联盟
Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·将asp页面转换成htm页面  (2007-11-20 16:39:46)
 ·ASP网站漏洞解析及黑客入侵防范方法完全版  (2007-11-20 15:34:37)
 ·asp实现有管理功能的ASP留言板  (2007-11-20 15:32:32)
 ·纯ASP(VBscript)写的全球IP地址搜索程序  (2007-11-20 15:26:48)
 ·asp.net ajax 使用updatepanel进行更新后的提示  (2007-11-20 15:20:28)
 ·Asp.net Ajax 1.0 异步回调时,服务器端Render原理1  (2007-11-20 15:19:45)
 ·ASP.NET--制作功能完善的安装程序  (2007-11-20 15:19:17)
 ·Asp.net直接保存文件到客户端  (2007-11-20 15:18:07)
 ·ASP.NET的 Session 详解  (2007-11-20 15:15:30)
 ·分析ASP.NET服务器控件开发-控件生命周期  (2007-11-20 15:11:15)