content_image/794882.jpg
+-------------------------------------+ | 0 | +-------------------------------------+ 1 row in set (0.01 sec) 

<img src='content_image/794882.jpg'>

mysql> SELECT -> ExtractValue(’<a>ccc<b>ddd</b></a>’, ’/a’) AS val1, -> ExtractValue(’<a>ccc<b>ddd</b></a>’, ’/a/b’) AS val2, -> ExtractValue(’<a>ccc<b>ddd</b></a>’, ’//b’) AS val3, -> ExtractValue(’<a>ccc<b>ddd</b></a>’, ’/b’) AS val4, -> ExtractValue(’<a>ccc<b>ddd</b><b>eee</b></a>’, ’//b’) AS val5; +------+------+------+------+---------+ | val1 | val2 | val3 | val4 | val5 | +------+------+------+------+---------+ | ccc | ddd | ddd | | ddd eee | +------+------+------+------+---------+ 

## Important 

ExtractValue()  returns only CDATA , and does not return any tags that might be contained within a matching tag, nor any of their content (see the result returned as val1  in the following example). 

This function uses the current SQL collation for making comparisons with contains() , performing the same collation aggregation as other string functions (such as CONCAT() ), in taking into account the collation coercibility of their arguments; see Section 10.8.4, “Collation Coercibility in Expressions” , for an explanation of the rules governing this behavior. 

(Previously, binary—that is, case-sensitive—comparison was always used.) 

NULL  is returned if xml_frag  contains elements which are not properly nested or closed, and a warning is generated, as shown in this example: 

mysql> SELECT ExtractValue(’<a>c</a><b’, ’//a’); +-----------------------------------+ | ExtractValue(’<a>c</a><b’, ’//a’) | +-----------------------------------+ | NULL | +-----------------------------------+ 1 row in set, 1 warning (0.00 sec) mysql> SHOW WARNINGS\G *************************** 1. row *************************** Level: Warning Code: 1525 Message: Incorrect XML value: ’parse error at line 1 pos 11: END-OF-INPUT unexpected (’>’ wanted)’ 1 row in set (0.00 sec) mysql> SELECT ExtractValue(’<a>c</a><b/>’, ’//a’); +-------------------------------------+ | ExtractValue(’<a>c</a><b/>’, ’//a’) | +-------------------------------------+ | c | +-------------------------------------+ 1 row in set (0.00 sec) 

