读xml文件

 #region  ReadMenu(string FilePath)读取配置文档中的信息
    /// <summary>
    /// 读取配置文档中的信息
    /// </summary>
    /// <param name="FilePath">网站配置文件</param>
    /// <param name="ArrayLength">数组长度</param>
    /// <param name="Obj_Source">对象长度</param>
    /// <returns></returns>
    private string ReadMenu(string FilePath)
    {
          if (!File.Exists(FilePath))
            {
                throw new Exception("文件不存在");
            }
            else
            {
                int i = 0;
                string IsChecked = string.Empty;

                XmlTextReader Reader = new XmlTextReader(FilePath);
                Reader.ReadStartElement("HouseSys");
                Reader.ReadStartElement("Show");
                while (Reader.Read())
                {
                    //判断该节点是否有属性
                    if (Reader.AttributeCount > 0)
                    {  //用循环判断完所有节点
                        while (Reader.MoveToNextAttribute())
                        {
                           
                            if (i == 0)
                            {
                                IsChecked = "checked";
                            }
                            else
                            {
                                IsChecked = "";
                            }
                            
                           
                            WebSystem += "<input type=\"radio\"  name=\"Rad_House\" value=\"" + Reader.Value +
                            "\" onclick=\"GetAboutInfo(this);\" " + IsChecked + "/>" +
                            Reader.ReadElementString()+"  &nbsp;";
                            i++;
                        }
                    }
                }

                return WebSystem;
            }

        }
 #endregion

posted @ 2007-05-28 17:04  世之云枭  阅读(179)  评论(0编辑  收藏  举报