I want to select elements other than the elements whose InEx value is 'Excluded'.
Here is my XML document:
<MachineStatus>
<ShiftStop MachineName="01" InEx="Excluded" />
<ShiftStop MachineName="01" InEx="Included" />
<ShiftStop MachineName="01" InEx="Included" />
</MachineStatus>
I need to get
<ShiftStop MachineName="01" InEx="Included" />
<ShiftStop MachineName="01" InEx="Included" />
I tried this query but it does not work.
SELECT [Entity].query('/MachineStatus/ShiftStop') FROM [FES].[SMD].[Machine] WHERE
[Entity].value('(/MachineStatus/ShiftStop/@InEx)[1]','varchar(10)') != 'Excluded'
When pulling values from XML, it does "rip" the entire tag, it extracts the elements. If you want to extract the values, and then get XML data back, you have to then rebuild the XML: