有人可以解释一下为什么这不起作用吗?
XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("Bing2_ss.xml");
//Instantiate an XmlNamespaceManager object.
XmlNamespaceManager xmlnsManager = new XmlNamespaceManager(xmlDoc.NameTable);
//Add the namespaces used in feed to the XmlNamespaceManager.
//xmlnsManager.AddNamespace("base", "https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Composite");
xmlnsManager.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
xmlnsManager.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices/");
xmlnsManager.AddNamespace(String.Empty, "http://www.w3.org/2005/Atom");
XmlNodeList nodeList;
XmlElement root = xmlDoc.DocumentElement;
nodeList = root.SelectNodes("//m:properties/d:WebTotal", xmlnsManager);
foreach (XmlNode nd in nodeList)
{
System.Console.WriteLine(nd.InnerText);
}
这是原始 xml: http: //gezond-afslanken.info/bing2_ss.xml