You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.1 KiB
91 lines
2.1 KiB
1 month ago
|
using System;
|
||
|
using System.IO;
|
||
|
using System.Xml;
|
||
|
using System.Data;
|
||
|
|
||
|
namespace SiaSun.LMS.Common
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// XmlFiles ��ժҪ˵����
|
||
|
/// </summary>
|
||
|
public class XmlFiles:XmlDocument
|
||
|
{
|
||
|
#region �ֶ�������
|
||
|
private string _xmlFileName;
|
||
|
public string XmlFileName
|
||
|
{
|
||
|
set{_xmlFileName = value;}
|
||
|
get{return _xmlFileName;}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region ------���캯��
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���캯��
|
||
|
/// </summary>
|
||
|
public XmlFiles() { }
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���캯��
|
||
|
/// </summary>
|
||
|
public XmlFiles(string xmlFile)
|
||
|
{
|
||
|
XmlFileName = xmlFile;
|
||
|
this.Load(xmlFile);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ------���ҽڵ�
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����һ���ڵ���xPath����ʽ������һ���ڵ�
|
||
|
/// </summary>
|
||
|
/// <param name="xPath">·��</param>
|
||
|
/// <returns></returns>
|
||
|
public XmlNode FindNode(string xPath)
|
||
|
{
|
||
|
XmlNode xmlNode = this.SelectSingleNode(xPath);
|
||
|
return xmlNode;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����һ���ڵ���xPath����ʽ������ֵ
|
||
|
/// </summary>
|
||
|
/// <param name="xPath">·��</param>
|
||
|
public string GetNodeValue(string xPath)
|
||
|
{
|
||
|
XmlNode xmlNode = this.SelectSingleNode(xPath);
|
||
|
return xmlNode.InnerText;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����һ���ڵ��ı���ʽ���ش˽ڵ��µĺ��ӽڵ��б�
|
||
|
/// </summary>
|
||
|
/// <param name="xPath">·��</param>
|
||
|
public XmlNodeList GetNodeList(string xPath)
|
||
|
{
|
||
|
XmlNodeList nodeList = this.SelectSingleNode(string.Format("descendant::Table[@Name='{0}']", xPath)).ChildNodes;
|
||
|
return nodeList;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ------����XML����DataTable
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����XML����DataTable
|
||
|
/// </summary>
|
||
|
public DataTable GetDataTable(string sXml)
|
||
|
{
|
||
|
XmlParserContext context = new XmlParserContext(null, null, null, XmlSpace.None);
|
||
|
XmlTextReader reader = new XmlTextReader(sXml, XmlNodeType.Document, context);
|
||
|
DataSet ds = new DataSet();
|
||
|
ds.ReadXml(reader);
|
||
|
return (ds.Tables.Count > 1) ? ds.Tables[1] : null;
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
}
|