I have a XML type variable @XMLData.
DECLARE @xmlData XML
DECLARE @tempXML XML
SET @xmlData =N'<ArrayOfResult>
<Result>
<ID>1</ID>
<Text>This text should be updated to new text</Text>
</Result>
<Result>
<ID>2</ID>
<Text>This text is okay</Text>
</Result>
</ArrayOfResult>';
I want to update the Text of the nodes where ID is 1.
I have tried this way
SET @tempXML = @xmlData
SELECT @xmlData;
SET @tempXML.modify('replace value of (/ArrayOfResult/Result/Text/text())[1] with ("This text is okay")');
SELECT @tempXML
But here, I have to mention the node index [1] to update first node. How can I update the Text element which have ID = 1 ?