I tried this query in Workbench and wonder why the second update //b[2] did not change?
SET @xml = '<a><b>111</b><b>222</b><b>333</b></a>';
SELECT
UpdateXML(@xml, '/a/b[1]',
Concat('<e>', Extractvalue(@xml,'//b[1]'),'</e>')) INTO @xml;
SELECT
UpdateXML(@xml, '/a/b[2]',
Concat('<e>', Extractvalue(@xml,'//b[2]'),'</e>')) INTO @xml;
SELECT
UpdateXML(@xml, '/a/b[3]',
Concat('<e>', Extractvalue(@xml,'//b[3]'),'</e>')) INTO @xml;
SELECT @xml
Here's the result:
+----------------------------------------+
| @xml |
+----------------------------------------+
|'<a><e>111</e><b>222</b><e>333</e></a>' |
+----------------------------------------+
The middle <b>222</b> should supposed to be changed to <e>222</e>. I've already checked every single letter in my code repeatedly.
Help please!...