1

Is there syntax to state 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"/>
baileyswalk
  • 1,198
  • 2
  • 17
  • 29

2 Answers2

1
xe2 = From c In xe.<el> Where c.@att1 = "ABC" And c.@att2 Is Nothing
NoAlias
  • 9,218
  • 2
  • 27
  • 46
1

Try String.IsNullOrEmpty(c.@att2).

tom redfern
  • 30,562
  • 14
  • 91
  • 126