zoukankan      html  css  js  c++  java
  • C# 获取xml里的值

     XmlDocument xmldoc = new XmlDocument();
                    string path = ApplicationPath;
                    path = path.Substring(0, path.LastIndexOf(@"\"));
                    path = path.Substring(0, path.LastIndexOf(@"\"));
                    path = path + @"\XMLLocalFile.xml";
                    xmldoc.Load(path);
                    int isChoice = -1;
                    string systemName = cboSystemName.Text.Trim();
                    txtServer.Text = cboSystemName.SelectedValue.ToString().Trim();
                    bool bl = false;
                    XmlNode root = xmldoc.SelectSingleNode("SystemName");
                    for (int i = 0; i < root.ChildNodes.Count; i++)
                    {
                        foreach (XmlAttribute att in root.ChildNodes[i].Attributes)
                        {
                            int findid = att.Name.IndexOf("ID");
                            if (findid > 1)
                            {
                                if (att.Value == systemName)
                                {
                                    isChoice = i;
                                    bl = true;
                                    break;
                                }
                            }
                        }
                        if (bl == true)
                        {
                            break;
                        }
                    }

                    if (isChoice == -1)
                    {
                        MessageBox.Show("配置文件找不到" + systemName + "的本地文件配置信息", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);

                    }
                    foreach (XmlAttribute att2 in root.ChildNodes[isChoice].Attributes)
                    {
                        int findid = att2.Name.IndexOf("ID");
                        if (findid < 0)
                        {
                            txtLocation.Text = (att2.Value).Trim();
                        }
                    }

  • 相关阅读:
    day01-h1字体大小和文本居中
    js正则表达式中的
    js滚动分页原理
    在web.xml中设置全局编码
    C# 导出word 表格代码
    C# 创建单例
    Winform 异步调用2 时间
    Winform 异步调用
    c#中跨线程调用windows窗体控件
    C# 中的委托和事件
  • 原文地址:https://www.cnblogs.com/lgxll/p/2549563.html
Copyright © 2011-2022 走看看