views:

1352

answers:

1

I have a problem with removing an attribute from a node.

Example:

DECLARE @processID int SET @processID = 8

DECLARE @xml XML SET @xml = ' '

SET @xml.modify('delete (/Process/Shapes/Shape/@subProcessID[/Process/Shapes/Shape/@subProcessID = sql:variable("@processID")])') SELECT @xml

Gives the result:

What I would like is:

What is the syntax to achieve this?

+1  A: 

Gives the result:

<Process id="10" name="Test 1">
  <Shapes>
    <Shape id="1" name="Shape 1" />
    <Shape id="2" name="Shape 2" />
  </Shapes>
  <Lines />
</Process>

What I whould like is :

<Process id="10" name="Test 1">
  <Shapes>
    <Shape id="1" name="Shape 1" />
    <Shape id="2" name="Shape 2" subProcessID="9" />
  </Shapes>
  <Lines />
</Process>