using System;
using System.Xml;
using System.Data;
namespace Message.Common
{
/// <summary>
/// XML相关通用功能
/// </summary>
public class Xml
{
public Xml() {}
/// <summary>
/// XML资源类型
/// </summary>
public enum XmlType
{
File,
String
};
#region 读取XML资源到DataSet中
/// <summary>
/// 读取XML资源到DataSet中
/// </summary>
/// <param name="source">XML资源,文件为路径,否则为XML字符串</param>
/// <param name="xmlType">XML资源类型</param>
/// <returns>DataSet</returns>
public static DataSet GetDataSet(string source, XmlType xmlType)
{
DataSet ds = new DataSet();
if (xmlType == XmlType.File)
{
ds.ReadXml(source);
}
else
{
XmlDocument xd = new XmlDocument();
xd.LoadXml(source);
XmlNodeReader xnr = new XmlNodeReader(xd);
ds.ReadXml(xnr);
}
return ds;
}
#endregion
#region 获取一个字符串xml文档中的ds
///<remarks>
///赵洪
///</remarks>
/// <summary>
/// 获取一个字符串xml文档中的ds
/// </summary>
/// <param name="xml_string">含有xml信息的字符串</param>
public static void get_XmlValue_ds(string xml_string,ref DataSet ds)
{
System.Xml.XmlDocument xd= new XmlDocument();