Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#当一个XML元素值是特定值时,获取另一个XML元素值_C#_Xml - Fatal编程技术网

C#当一个XML元素值是特定值时,获取另一个XML元素值

C#当一个XML元素值是特定值时,获取另一个XML元素值,c#,xml,C#,Xml,只有当等于0时,C#中是否有可能获得节点的值 如果不是,我将如何解析IsDisabled值为0的PropertyID 我一整天都在用这个折磨自己,所以任何帮助都将不胜感激 我在下面附上了我的XML的一个示例片段。我已经对它进行了显著的压缩,其中许多值为1,许多值为0 <response> <code>200</code> <result> <PhysicalProperty> <Property>

只有当
等于0时,C#中是否有可能获得
节点的值

如果不是,我将如何解析IsDisabled值为0的PropertyID

我一整天都在用这个折磨自己,所以任何帮助都将不胜感激

我在下面附上了我的XML的一个示例片段。我已经对它进行了显著的压缩,其中许多值为1,许多值为0

<response>
  <code>200</code>
  <result>
    <PhysicalProperty>
      <Property>
        <PropertyID>325213</PropertyID>
        <MarketingName>XXXXX</MarketingName>
        <Type>Student</Type>
        <IsDisabled>1</IsDisabled>
        <IsFeaturedProperty>0</IsFeaturedProperty>
      </Property>
    </PhysicalProperty>
  </result>
</response>

是的,LINQ使对XML执行这些类型的查询变得非常容易

var propertyIds = XDocument.Parse(myXmlString)
                           .Descendants("Property")
                           .Where(p => p.Element("IsDisabled").Value == "0")
                           .Select(p => p.Element("PropertyID").Value);

好啊我有点明白了。在此上下文中,p在代码中的含义是什么?
=>
表示匿名方法。左侧(p)是进入方法的参数,右侧是方法主体。您可以研究
匿名方法
lambda