*************************************************** 说明:person类 作者:gwd 2002-11-06 引用:pub/constpub.asp ***************************************************
class cls_person
private m_intid id,对应person节点在persons集合中的位置 private m_strname 姓名 private m_strnick 英文名 private m_strmobile 手机 private m_strtel 电话 private m_stremail 电子邮件 private m_strqq qq号 private m_strcompany 所在公司 private m_strerror 出错信息
类初始化 private sub class_initialize() m_strerror = "" m_intid = -1 end sub
类释放 private sub class_terminate() m_strerror = "" end sub
-----读写各个属性---------------------------
public property get id id = m_intid end property
public property let id(intid) m_intid = intid end property
public property get name name = m_strname end property
public property let name(strname) m_strname = strname end property
public property get nick nick = m_strnick end property
public property let nick(strnick) m_strnick = strnick end property
public property get mobile mobile = m_strmobile end property
public property let mobile(strmobile) m_strmobile = strmobile end property
public property get tel tel = m_strtel end property
public property let tel(strtel) m_strtel = strtel end property
public property get email email = m_stremail end property
public property let email(stremail) m_stremail = stremail end property
public property get qq qq = m_strqq end property
public property let qq(strqq) m_strqq = strqq end property
public property get company company = m_strcompany end property
public property let company(strcompany) m_strcompany = strcompany end property
-----------------------------------------------
获取错误信息 public function getlasterror() getlasterror = m_strerror end function
私有方法,添加错误信息 private sub adderr(strecho) m_strerror = m_strerror + "<div class=""alert"">" & strecho & "</div>" end sub
清除错误信息 public function clearerror() m_strerror = "" end function
从xml(标准化越来越近了)中读取指定节点的数据,并填充各个属性 需要首先设置id public function getinfofromxml(标准化越来越近了)(objxml(标准化越来越近了)doc) dim objnodelist dim i
clearerror
if objxml(标准化越来越近了)doc is nothing then getinfofromxml(标准化越来越近了) = false adderr "dom对象为空值" exit function end if
if cstr(m_intid) = "-1" then getinfofromxml(标准化越来越近了) = false adderr "未正确设置联系人对象的id属性" exit function else i = m_intid - 1 要读取得节点位置 end if
选择并读取节点信息,赋予各个属性 set objnodelist = objxml(标准化越来越近了)doc.getelementsbytagname("person") if objnodelist.length - m_intid >= 0 then on error resume next m_strname = objnodelist(i).selectsinglenode("name").text m_strnick = objnodelist(i).selectsinglenode("nick").text m_strmobile = objnodelist(i).selectsinglenode("mobile").text m_strtel = objnodelist(i).selectsinglenode("tel").text m_stremail = objnodelist(i).selectsinglenode("email").text m_strqq = objnodelist(i).selectsinglenode("qq").text m_strcompany = objnodelist(i).selectsinglenode("company").text getinfofromxml(标准化越来越近了) = true else getinfofromxml(标准化越来越近了) = false adderr "获取联系信息发生错误" set objnodelist = nothing exit function end if set objnodelist = nothing end function
添加信息到xml(标准化越来越近了)文件中 需要首先设置好要填充的属性 public function addtoxml(标准化越来越近了)(objxml(标准化越来越近了)doc) dim objperson, objnode
clearerror
if objxml(标准化越来越近了)doc is nothing then addtoxml(标准化越来越近了) = false adderr "dom对象为空值" exit function end if
创建person节点 set objperson = objxml(标准化越来越近了)doc.createelement("person") objxml(标准化越来越近了)doc.documentelement.appendchild objperson
创建各个子节点 ----------------------------------------------------- set objnode = objxml(标准化越来越近了)doc.createelement("name") objnode.text = m_strname objperson.appendchild objnode
set objnode = objxml(标准化越来越近了)doc.createelement("nick") objnode.text = m_strnick objperson.appendchild objnode
set objnode = objxml(标准化越来越近了)doc.createelement("mobile") objnode.text = m_strmobile objperson.appendchild objnode
set objnode = objxml(标准化越来越近了)doc.createelement("tel") objnode.text = m_strtel objperson.appendchild objnode
set objnode = objxml(标准化越来越近了)doc.createelement("email") objnode.text = m_stremail objperson.appendchild objnode
set objnode = objxml(标准化越来越近了)doc.createelement("qq") objnode.text = m_strqq objperson.appendchild objnode
set objnode = objxml(标准化越来越近了)doc.createelement("company") objnode.text = m_strcompany objperson.appendchild objnode -----------------------------------------------------
set objnode = nothing set objperson = nothing
on error resume next objxml(标准化越来越近了)doc.save server.mappath(c_xml(标准化越来越近了)file) 保存xml(标准化越来越近了)文件 if err.number = 0 then addtoxml(标准化越来越近了) = true else addtoxml(标准化越来越近了) = false adderr err.description end if end function
从xml(标准化越来越近了)文件中删除数据 需要首先设置id public function deletefromxml(标准化越来越近了)(objxml(标准化越来越近了)doc) dim objnodelist, objnode
clearerror
if objxml(标准化越来越近了)doc is nothing then deletefromxml(标准化越来越近了) = false adderr "dom对象为空值" exit function end if
if cstr(m_intid) = "-1" then deletefromxml
|