我爱Aspx >> Asp.Net >> c#操作xml类public class XmlControl
{
protected string strXmlFile;
protected XmlDocument objXmlDoc = new XmlDocument();
public XmlControl(string XmlFile)
{
//
// TODO: 在這裡加入建構函式的程式碼
//
try
{
objXmlDoc.Load(XmlFile);
}
catch (System.Exception ex)
{
throw ex;
}
strXmlFile = XmlFile;
}
public DataView GetData(string XmlPathNode)
{
//查找數據。返回一個DataView
DataSet ds = new DataSet();
StringReader read = new StringReader(objXmlDoc.SelectSingleNode(XmlPathNode).OuterXml);
ds.ReadXml(read);
return ds.Tables[0].DefaultView;
}
public void Replace(string XmlPathNode,string Content)
{
//更新節點內容。
objXmlDoc.SelectSingleNode(XmlPathNode).InnerText = Content;
}
public void Delete(string Node)
{
//刪除一個節點。
string mainNode = Node.Substring(0,Node.LastIndexOf("/"));
objXmlDoc.SelectSingleNode(mainNode).RemoveChild(objXmlDoc.SelectSingleNode(Node));
}
public void InsertNode(string MainNode,string ChildNode,string Element,string Content)
{
//插入一節點和此節點的一子節點。
XmlNode objRootNode = objXmlDoc.SelectSingleNode(MainNode);
XmlElement objChildNode = objXmlDoc.CreateElement(ChildNode);
objRootNode.AppendChild(objChildNode);
XmlElement objElement = objXmlDoc.CreateElement(Element);
Ҷƪл˵?
C#静态页面生成[04-21]
如何开发一个多种语言版本的C#程..[04-21]
c#.net存储过程版本的分页[04-21]
学习C#静态函数及变量的一个精典..[04-21]
用C#绘柱形图(owc编程)[04-21]
解读C#中的规则表达式(正则表达..[04-21]
C#中的特性(Attributes)[04-21]
几个C#写的网络相关开源组件[04-21]
c#学习体会:使用 ref 和 out 传递..[04-21]
c#中使用ref和out一点认识[04-21]
本站photos模块代码[04-21]
网页常用效果和知识[04-21]
清空页面缓存[04-21]
初次体验.net Ajax无刷新技术[04-21]
在vs2005 web程序里如何做固定表..[04-21]
Ajax基础-服务器端ASP.net脚本请..[04-21]
C#静态页面生成[04-21]
如何开发一个多种语言版本的C#程..[04-21]
c#.net存储过程版本的分页[04-21]
学习C#静态函数及变量的一个精典..[04-21]