|
 |
栏目导栏 |
|
| |
|
|
|
|
 |
资料搜索 |
|
| |
|
|
|
|
 |
热门文章 |
|
| |
|
|
|
|
 |
最新文章 |
|
| |
|
|
|
| |
| |
|
|
|
|
<% 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论坛讨论 |
|
|
|
|
|