我原来使用xml做配置文件,然后经过加密解密后得到一个字符串,例如
string sss=
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<Configuration>\r\n  <CompanyInfo><!--公司信息-->\r\n    <Name></Name>\r\n    <Tel></Tel>\r\n    <Fax></Fax>\r\n    <Addr></Addr>\r\n  </CompanyInfo>\r\n ";现在我想把这个字符串又转换为xml读取信息,比如我要读取CompanyInfo节点信息,
System.Xml.XmlDocument xml = new System.Xml.XmlDocument();
System.Xml.XmlNodeList list = xml.SelectSingleNode("Configuration").SelectSingleNode("CompanyInfo");
怎么把这个字符串的内容装载到System.Xml.XmlDocument xml里面去啊??不要用截取字符串的方式啊!

解决方案 »

  1.   

     XmlDocument _Documnet = new XmlDocument();
                _Documnet.LoadXml(sss);
      

  2.   


    string sss = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<Configuration>\r\n <CompanyInfo><!--公司信息-->\r\n <Name></Name>\r\n <Tel></Tel>\r\n <Fax></Fax>\r\n <Addr></Addr>\r\n </CompanyInfo>\r\n</Configuration> ";            StringReader sr = new StringReader(sss);
                
        
                  
                XmlDocument doc = new XmlDocument();           doc.Load(sr);
               System.Xml.XmlNode list = doc.SelectSingleNode("Configuration").SelectSingleNode("CompanyInfo");
      

  3.   

    使用stringReader专门处理字符串