日期:2014-01-19  浏览次数:20836 次

C#操作XML初步(8)
第四章:通用的XML处理方法(2)
上一篇,我们提供了一个类,用来操作XML文件,这里提供一个应用的例子,来源于无聊时候写的一个XML留言本中对留言数据的处理
代码如下: using System; 
using System.IO; 
using System.Data; 
using System.Diagnostics; 
using XmlBook.Com.Sem.Tools;   //这里就包含了上一篇提供的类 

namespace XmlBook.Component 

 /// <summary> 
 /// 版权: Copyright by SEM IT Department 
 /// 版本: 0.0.1 
 /// 文件: XmlBook.Component.MdlDataMange.cs 
 /// 目的: 留言数据相关的操作 
 /// 作者: 欧远宁 @2005-04-09 
 /// 邮箱: outrace@soueast-motor.com 
 /// 修改: 
 /// </summary> 
 public class MdlDataManage 
 { 

  #region 私有成员 
  private string strID = null; 
  private string strName = null; 
  private string strSex = null; 
  private string strEmail = "no email"; 
  private string strPage = "no page"; 
  private string strQQ = "no QQ"; 
  private string strSubject = null; 
  private string strContent = null; 
  private string strReply = "no reply"; 
  private string strFilter = null; 
  #endregion 
   
  #region 公有成员 
  /// <summary> 
  /// 姓名 
  /// </summary> 
  public string StrName 
  { 
   get{return this.strName;} 
   set{this.strName = value;} 
  } 
  /// <summary> 
  /// 性别 
  /// </summary> 
  public string StrSex 
  { 
   get{return this.strSex;} 
   set{this.strSex = value;} 
  } 
  /// <summary> 
  /// 邮箱 
  /// </summary> 
  public string StrEmail 
  { 
   get{return this.strEmail;} 
   set{this.strEmail = value;} 
  } 
  /// <summary> 
  /// 主页 
  /// </summary> 
  public string StrPage 
  { 
   get{return this.strPage;} 
   set{this.strPage = value;} 
  } 

  /// <summary> 
  /// OICQ号码 
  /// </summary> 
  public string StrQQ 
  { 
   get{return this.strQQ;} 
   set{this.strQQ = value;} 
  } 
  /// <summary> 
  /// 主题 
  /// </summary> 
  public string StrSubject 
  { 
   get{return this.strSubject;} 
  &