【www.gdgbn.com--文本特效】


<%
"----------------------------------------------------------------
"程序简介: 完成asp教程语言对xml文档中指定节点文本的增加、删除、修改、查看
"入口参数: 无
"出口参数: 无
"------------------------------------------------
"函数名字:connectxml()
"入口参数: filename 需要连接或打开的xml文件名
"出口参数: 无
"返回值 :connectxml=0,xmlmorntekdocument就是一个成功装载xml文档的对象了。
" connectxml<>0,则打印错误信息strerror
"------------------------------------------------
dim xmlmorntekdocument

function connectxml(filename)
dim strsourcefile
strsourcefile = server.mappath(filename)
set xmlmorntekdocument = server.createobject(" microsoft.xmldom")
xmlmorntekdocument.async = false
xmlmorntekdocument.load(strsourcefile)
connectxml=xmlmorntekdocument.parseerror.errorcode
if xmlmorntekdocument.parseerror.errorcode<>0 then
strerror="

error"&xmlmorntekdocument.parseerror.errorcode&"

"
strerror=strerror&xmlmorntekdocument.parseerror.reason&"
"
strerror=strerror&xmlmorntekdocument.parseerror.url&"
"
strerror=strerror&xmlmorntekdocument.parseerror.line&"
"
strerror=strerror&xmlmorntekdocument.parseerror.filepos&"
"
strerror=strerror&xmlmorntekdocument.parseerror.srctext&"
"
response.write strerror
end if
end function

"------------------------------------------------
"函数名字:closexml()
"入口参数: 无
"出口参数: 无
"------------------------------------------------
function closexml(xmlmorntekdocument)
if isobject(xmlmorntekdocument) then
set xmlmorntekdocument=nothing
end if
end function


"------------------------------------------------
"函数名字:selectxmlnodetext(elementname)
"入口参数: elementname 元素的名字
"出口参数: 无
"------------------------------------------------
function selectxmlnodetext(elementname)
elementname="//"&elementname
temp=xmlmorntekdocument.selectsinglenode(elementname).text
selectxmlnodetext= server.htmlencode(temp)

end function

"------------------------------------------------
"函数名字:insertxmlnodetext(befelementname,elementname,elementtext)
"入口参数: elementname 插入的元素的名字
" befelementname在此元素的名字前面插入元素
" elementtext 插入的元素的文本
"出口参数: 无
"------------------------------------------------
function insertxmlnodetext(befelementname,elementname,elementtext)
dim befelement,element
set befelement=xmlmorntekdocument.selectsinglenode("//"&befelementname)
set element= xmlmorntekdocument.createelement(elementname)
befelement.insertbefore element,befelement.firstchild
element.text=elementtext
end function

"------------------------------------------------
"函数名字:updatexmlnodetext(elementname,newelementtext)
"入口参数: elementname 元素的名字
" newelementtext元素的新文本
"出口参数: 无
"------------------------------------------------
function updatexmlnodetext(elementname,newelementtext)
dim element
set element=xmlmorntekdocument.selectsinglenode("//"&elementname)
element.text=newelementtext
end function

"------------------------------------------------
"函数名字:deletexmlnodetext(elementname)
"入口参数: elementname 元素的名字
"出口参数: 无
"------------------------------------------------
function deletexmlnodetext(elementname)
xmlmorntekdocument.selectsinglenode("//"&elementname).text =""
end function
%>

本文来源:http://www.gdgbn.com/wangyetexiao/29243/