Which namespace is necessary to use SelectSingleNode() method (using default namespace and can't use the method)

穿精又带淫゛_ 提交于 2019-11-29 17:00:42

You need to use the correct namespace, which is "http://schemas.microsoft.com/developer/msbuild/2003".

Try

XmlDocument xml = new XmlDocument();
xml.Load("ref.props");        
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xml.NameTable);
nsmgr.AddNamespace("ms", "http://schemas.microsoft.com/developer/msbuild/2003");

XmlNode platform_node
  = xml.SelectSingleNode("/ms:Project/ms:PropertyGroup[contains(@Condition, '1111')]",
                         nsmgr);

Don't confuse the namespace prefix (which was empty in the XML) with the namespace, which is "http://schemas.microsoft.com/developer/msbuild/2003".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!