<?xml version="1.0" encoding="utf-8"?><string xmlns="http://tempuri.org/">-4456116940642369971</string>
请问如何读取到里面的-4456...的数据?跪求大神教教小弟....

解决方案 »

  1.   

     string xml = @" <?xml version=""1.0"" encoding=""utf-8""?><string xmlns=""http://tempuri.org/"">-4456116940642369971</string>";
                var txt = Regex.Match(xml, @"(?i)<string[^>]+>([^<]+)</string>").Groups[1].Value;
                Console.WriteLine(txt);
               
      

  2.   


    System.Xml.Linq.XElement ele = XElement.Load("app.xml");
    string va = ele.Value;
    把这个
    <?xml version="1.0" encoding="utf-8"?><string xmlns="http://tempuri.org/">-4456116940642369971</string>
    XML字符串写成XML文件,然后使用linq去读取
      

  3.   

      XmlDocument xmlDoc=new XmlDocument();
      xmlDoc.Load(System.Web.HttpContext.Current.Server.MapPath("xml路径"));
      XmlNode xn = xmlDoc.SelectSingleNode("string ");
      string value=xn.InnerText;
      

  4.   

    XmlDocument xmlDoc=new XmlDocument();
    xmlDoc.Load(@"路径");
    //如果从字符串加载:xmlDoc.LoadXml("xml文本字符串");
    Response.Write(xmlDoc.DocumentElement.InnerText);