我有一个简单的XML,
<S xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><H></H></S>
Run Code Online (Sandbox Code Playgroud)
我想找到所有"H"节点.
XElement x = XElement.Parse("<S xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><H></H></S>");
IEnumerable<XElement> h = x.Descendants("H");
if (h != null)
{
}
Run Code Online (Sandbox Code Playgroud)
但是这段代码不起作用.当我从S标记中删除命名空间时,代码正常工作.