asp.net中,使用XDocument操作XML

来源:互联网 发布:服务端面试常见算法题 编辑:程序博客网 时间:2024/06/05 00:32
Label lblState = (Label)dvProjectDetails.FindControl("lblState");
                    XDocument xdocSolvers = XDocument.Load(Server.MapPath("~/config/solvers.xml"));
                    string sDescription = "";
                    //CommonConfig.SolverCollection.SolverMainCollection
                    foreach (var item in xdocSolvers.Element("Solvers").Elements())
                    {
                        if (item.Attribute("Name").Value == ViewState[@"SolverName"].ToString())
                        {
                            foreach (var item2 in item.Elements())
                            {
                                if (item2.Attribute("Value").Value == ViewState[@"SolverVersion"].ToString())    
                                {
                                    sDescription = item2.Element("Type").Element("Description").Attribute("Value").Value;
                                    break;
                                }
                            }
                            break;
                        }
                    }
                    lblState.Attributes.Add("onmouseover", "tooltip.show('"+sDescription+"');");
                    lblState.Attributes.Add("onmouseout", "tooltip.hide();");





// add for tooltip
                if (sState != "Finished")
                {
                    Label lblState = (Label)dvProjectDetails.FindControl("lblState");
                    string sDescription = "";
                    string solver = ViewState[@"SolverName"].ToString();
                    string version = ViewState[@"SolverVersion"].ToString();
                    string type = ViewState[@"OsType"].ToString();
                    if (CommonConfig.SolverCollection.SolverMainCollection.ContainsKey(solver))
                    {
                        if (CommonConfig.SolverCollection.SolverMainCollection[solver].SolverVersionCollection.ContainsKey(version))
                        {
                            if (CommonConfig.SolverCollection.SolverMainCollection[solver].SolverVersionCollection[version].SolverTypeCollection.ContainsKey(type))
                            {
                                sDescription = CommonConfig.SolverCollection.SolverMainCollection[solver].SolverVersionCollection[version].SolverTypeCollection[type].Description;
                                if (!string.IsNullOrEmpty(sDescription))
                                {
                                    lblState.Attributes.Add("onmouseover", "tooltip.show('" + sDescription + "');");
                                    lblState.Attributes.Add("onmouseout", "tooltip.hide();");
                                }
                            }
                        }                        
                    }                    
                }
原创粉丝点击