当前位置: 网学 > 编程文档 > ASP > 正文

实例演练ASP+XML编程

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/17
下载{$ArticleTitle}原创论文样式

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(objXmlDoc)
 Dim objNodeList
 Dim I

 ClearError

 If objXmlDoc 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 = objXmlDoc.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(objXmlDo

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号