开发者

LinqToXml; query where attribute does not exist

开发者 https://www.devze.com 2023-04-12 17:40 出处:网络
Is there syntax to st开发者_开发百科ate where attribute does not exist? Dim xe As XElement = _ <xml>

Is there syntax to st开发者_开发百科ate where attribute does not exist?

    Dim xe As XElement = _
    <xml>
        <el att1="ABC" att2="XYZ"/>
        <el att1="ABC"/>
        <el/>
    </xml>

    Dim xe2 As IEnumerable(Of XElement)
    xe2 = From c In xe.<el> Where c.@att1 = "ABC" And DoesNotExist(c.@att2)

    'Return: <el att1="ABC"/>


xe2 = From c In xe.<el> Where c.@att1 = "ABC" And c.@att2 Is Nothing


Try String.IsNullOrEmpty(c.@att2).

0

精彩评论

暂无评论...
验证码 换一张
取 消