編寫此案例的目的是為了描述在普通的應用程序中如何運用DOM技術以及對上一篇文章《C#中使用XML——實現DOM》中所講述的DOM的相關知識回顧一下
以下是程序運行效果圖
應用程序主窗體
添加聯系人窗體
修改聯系人窗體
以下是用於測試程序的XML文件
contact
<?xml version=
<ContactDetails>
<Contact>
<name>
<first>Steven</first>
<last>Perez</last>
</name>
<note>
</Contact>
<Contact>
<name>
<first>Billoys</first>
<last>Perez</last>
</name>
<note>;system at </note>
</Contact>
<Contact>
<name>
<first>劉</first>
<last>羅鍋</last>
</name>
<note>古代人</note>
</Contact>
</ContactDetails>
contact
<?xml version=
<ContactDetails>
<Contact>
<name>
<first>Steven</first>
<last>Perez</last>
</name>
<note>
</Contact>
<Contact>
<name>
<first>Billoys</first>
<last>Perez</last>
</name>
<note>;system at </note>
</Contact>
<Contact>
<name>
<first>劉</first>
<last>德華</last>
</name>
<note>香港著名藝人
</Contact>
<Contact>
<name>
<first>揚</first>
<last>震</last>
</name>
<note>重案六組探員
</Contact>
<Contact>
<name>
<first>季</first>
<last>潔</last>
</name>
<note>重案六組探員
</Contact>
</ContactDetails>
導出聯系人時在
為實現以上所述所有功能
namespace ContactApplication
{
using System;
using System
using System
using System
using System
using System
using System
/// <summary>
/// Contact 聯系人
/// </summary>
public class Contact : IDisposable
{
private string xmlPath;
private XmlDocument xmlDoc;
private XmlNode selectNode;
private string firstName;
private string lastName;
private string note;
#region Contact 構造器
/// <summary>
/// 默認構造器
/// </summary>
public Contact()
{
this
this
this
this
this
this
this
}
/// <summary>
/// 使用姓氏
/// </summary>
/// <param name=
/// <param name=
/// <param name=
public Contact(string firstName
{
this
this
this
this
this
this
this
}
#endregion
#region Contact 資源釋放方法
/// <summary>
/// 清理該對象所有正在使用的資源
/// </summary>
public void Dispose()
{
this
GC
}
/// <summary>
/// 釋放該對象的實例變量
/// </summary>
/// <param name=
protected virtual void Dispose(bool disposing)
{
if (!disposing)
return;
if (this
this
if (this
this
if (this
this
if (this
this
if (this
this
if (this
this
}
#endregion
#region Contact 屬性
/// <summary>
/// 姓氏
/// </summary>
public string FirstName
{
get
{
return this
}
set
{
this
}
}
/// <summary>
/// 名字
/// </summary>
public string LastName
{
get
{
return this
}
set
{
this
}
}
/// <summary>
/// 個人信息
<
From:http://tw.wingwit.com/Article/program/net/201311/12660.html