<NodeList>
 <Node text="GWGL"></Node>
 <Node text="手册备案" clsid="表头">&">

读取XML文件

80酷酷网    80kuku.com

  xml

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 = Targetnode.ChildNodes.Count;
                    List = new string[Count];
                    for (int j = 0; j < Count; j++)
                    {
                        List[j] = Targetnode.ChildNodes[j].InnerText;
                    }
                    ExtendTable = List[0];
                    //for (int i = 1; i < Count; i++)
                    //{
                    //    ColumnName[i] = List[i];
                    /

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: