<?xml version="1.0" encoding="utf-8" ?> 
  <string xmlns="http://tempuri.org/">-5</string> 
我要取-5出来

解决方案 »

  1.   


    //这样的可以吧(C#的):
    //上面的加载省略哈……
    XmlNode node = xmlDoc.SelectSingleNode("string");
    string nodeText = node.InnerText;
    //nodeText就是获取的值
      

  2.   


     应该有好几种方法的,下面我说2种
     1种是3楼说的通过DataSet 读取xml 然后在DataSet里取  DataSet ds = new DataSet();
      ds.ReadXml(Server.MapPath("xmlFile.xml"));
      以下就不说了
     
     2种是通过XmlDocument
             XmlDocument xmlDoc = new XmlDocument();
             xmlDoc.Load(this.m_xmlFilePath);
             System.Xml.XmlNodeList xmlNL = xmlDoc.SelectNodes("string"); 
             ....
      

  3.   

    不对呀那里来的xmlFile.xml
    我现在只有一个字符串内容是:
    <?xml version="1.0" encoding="utf-8" ?> 
      <string xmlns="http://tempuri.org/">-5 </string> 
    我要取-5出来
      

  4.   

    XmlDocument xmlDoc = new XmlDocument(); 
    smlDoc.LoadXml(/*字符串*/);
      

  5.   

    打错了 是
    XmlDocument xmlDoc = new XmlDocument(); 
    xmlDoc.LoadXml(/*字符串*/);
      

  6.   

    XmlDocument xmlDoc = new XmlDocument(); 
    xmlDoc.LoadXml(/*字符串*/);
    XmlNode xn0 = xmlDoc.SelectSingleNode("string")
    string result = xn0.InnerText;
    result为 -5
      

  7.   

       XmlDocument xmlDoc = new XmlDocument();
                                xmlDoc.LoadXml(s);
                                XmlNode node = xmlDoc.SelectSingleNode("http://tempuri.org/");
    出现异常怎么回事
      

  8.   

    http://tempuri.org/'”具有无效的标记
      

  9.   

     XmlNode node = xmlDoc.SelectSingleNode("http://tempuri.org/"); 
    NODE("*****");  ***代表的是你的结点名称,“http://tempuri.org/”不是你的结点,怎么能够填写进去呢?
      

  10.   

    http://tempuri.org/ 这个是属性值
      

  11.   

      XmlDocument xmlDoc = new XmlDocument();
                               xmlDoc.LoadXml(s);
                               XmlNode node = xmlDoc.SelectSingleNode("string");
    //这样都不对你们验证过我这样得到一个NULL
                              string nodeText = node.InnerText;
    这样都不对你们验证过我这样得到一个NULL
      

  12.   


     完全搞定了            XmlDocument xmlDoc = new XmlDocument();
               xmlDoc.Load(Server.MapPath("XMLFile.xml"));
               String ss = xmlDoc.GetElementsByTagName("string")[0].Attributes[0].Value.ToString();
      

  13.   


      这个取值,上面的取属性值
      
        String sss = xmlDoc.GetElementsByTagName("string")[0].InnerText.ToString();
      

  14.   

    XmlNode node = xmlDoc.SelectSingleNode("string");
    string nodeText = node.InnerText;