string mms = doc.SelectSingleNode("//XsPlaySource/OutputData/PlaySources/PlaySource").InnerText;最开始那个改成//

解决方案 »

  1.   

    注意命名空间
     
    XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
          nsmgr.AddNamespace("bk", "urn:samples");      //Select the book node with the matching attribute value.
          XmlNode book;
          XmlElement root = doc.DocumentElement;
          book = root.SelectSingleNode("descendant::book[@bk:ISBN='1-861001-57-6']", nsmgr);
      

  2.   

    反正就一个,直接用doc.GetElementsByTagName(string)返回一个集合,也不用判断了
      

  3.   

    try..            string strinfo = "<?xml version=\"1.0\" encoding=\"gb2312\"?><XsPlaySource xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://roxbeam.com/RMS/DPC/Subscribe/XsPlaySource.xsd\"><OutputData><PlaySources><PlayType>MMS</PlayType><PlaySource>mms://vod.phoenixtv.com/2006/rox/2007/01/05/8d2bbb48-70b3-41d3-8c1a-c9cccb7e705f.wmv</PlaySource></PlaySources></OutputData></XsPlaySource>";
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(strinfo.Replace("gb2312", "UTF-8"));
                XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
                nsmgr.AddNamespace("msg", "http://roxbeam.com/RMS/DPC/Subscribe/XsPlaySource.xsd");
                XmlElement root = doc.DocumentElement;
                XmlNode node = root.SelectSingleNode("/msg:XsPlaySource/msg:OutputData/msg:PlaySources/msg:PlaySource", nsmgr);
                Console.WriteLine(node.InnerText);
      

  4.   

    输出:mms://vod.phoenixtv.com/2006/rox/2007/01/05/8d2bbb48-70b3-41d3-8c1a-c9cccb7e705f.wmv