给你个参考
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;namespace Framework
{
    public class ConfigHelper
    {
        private XmlDocument _xmlDoc = new XmlDocument();        private string _xmlPath = string.Empty;
        /// <summary>
        /// 
        /// </summary>
        public string XmlPath
        {
            get { return _xmlPath; }
            set { _xmlPath = value; }
        }        /// <summary>
        /// 
        /// </summary>
        public ConfigHelper()
        {
            
        }        public ConfigHelper(string path)
        {
            _xmlDoc.Load(path);
        }        /// <summary>
        /// 
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public ConfigInfo GetConfigInfo(string condition)
        {
            ConfigInfo configInfo = new ConfigInfo();            XmlElement root = _xmlDoc.DocumentElement;
            XmlNode node = root.SelectSingleNode(condition);            XmlNode objectNode = node.ChildNodes[0];            configInfo.AssemblyName = objectNode.Attributes["assembly"].Value;
            configInfo.ObjectName = objectNode.Attributes["name"].Value;
            configInfo.TypeName = objectNode.Attributes["typeName"].Value;            XmlNode propertyNode = objectNode.ChildNodes[0];            configInfo.ObjectPropertyInfo = new ConfigInfo.PropertyInfo();
            configInfo.ObjectPropertyInfo.AssemblyName = propertyNode.Attributes["assembly"].Value;
            configInfo.ObjectPropertyInfo.PropertyName = propertyNode.Attributes["name"].Value;
            configInfo.ObjectPropertyInfo.TypeName = propertyNode.Attributes["typeName"].Value;            return configInfo;
        }
    }
}

解决方案 »

  1.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace Framework
    {
        public class ConfigInfo
        {
            public string ObjectName
            { get; set; }        public string AssemblyName
            { get; set; }        public string TypeName
            { get; set; }        public PropertyInfo ObjectPropertyInfo
            { get; set; }        public class PropertyInfo
            {
                public string PropertyName
                { get; set; }            public string AssemblyName
                { get; set; }            public string TypeName
                { get; set; }
            }
        }
    }