<%
'----------------------------------------------------------------
'程序简介: 完成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="<h2>error"&xmlmorntekdocument.parseerror.errorcode&"</h2>"
strerror=strerror&xmlmorntekdocument.parseerror.reason&"<br>"
strerror=strerror&xmlmorntekdocument.parseerror.url&"<br>"
strerror=strerror&xmlmorntekdocument.parseerror.line&"<br>"
strerror=strerror&xmlmorntekdocument.parseerror.filepos&"<br>"
strerror=strerror&xmlmorntekdocument.parseerror.srctext&"<br>"
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
%>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器