日期:2014-04-15  浏览次数:20951 次

1、xml文件格式


<?xml version="1.0" encoding="utf-8" ?>
<NodeList>
 <Node text="GWGL"></Node>
 <Node text="手册备案" clsid="表头">
    <Name>GWGL.EP_PRE_EMS3_CUS_HEAD</Name>
    <Value>TRADE_CODE</Value>
 </Node>
 <Node text="手册备案" clsid="单损耗">
    <Name>GWGL.EP_PRE_EMS3_CUS_CONSUME</Name>
    <Value>TRADE_CODE</Value>
    <Value>EXG_NO</Value>
    <Value>IMG_NO</Value>
 </Node>
</NodeList>
2、读取XML文件的函数

/// <summary>
        /// 读取XML文件
        /// </summary>
        /// <param name="Name">节点名称</param>
        /// <param name="classid">扩展选项类别</param>
        /// <param name="DataObj">数据源</param>
        public void ReadXML(string Name, string classid, DataRowView DataObj)
        {
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(Application.StartupPath + "\\Configure.xml");
                XmlNodeList node = doc.SelectSingleNode("NodeList").ChildNodes;
                XmlNode Targetnode = null;
                string s = node[0].Attributes["text"].Value;
                for (int i = 1; i < node.Count; i++)
                {
                    if (node[i].Attributes["text"].Value == Name
                        && node[i].Attributes["clsid"].Value == classid )
                    {
                        Targetnode = node[i];
                        break;
                    }
                }
                if (Targetnode != null)
                {
                    //this.toolStrip1.Visible = true;
                    Count = Targ