XML Functions If no expression matching  xpath_expr  is found, or if multiple matches are found, the function returns the original  xml_target  XML fragment. All three arguments should be strings. A discussion in depth of XPath syntax and usage are beyond the scope of this manual. Please see the XML Path Language (XPath) 1.0 specification for definitive information. A useful resource for those new to XPath or who are wishing a refresher in the basics is the Zvon.org XPath Tutorial, which is available in several languages. Descriptions and examples of some basic XPath expressions follow: Matches  < tag />  if and only if  < tag />  is the root element. Example:  /a  has a match in  <a><b/></a>  because it matches the outermost (root) tag. It does not match the inner  a  element in  <b><a/></b>  because in this instance it is the child of another element. Matches  < tag2 />  if and only if it is a child of  < tag1 /> , and  < tag1 />  is the root element. Example:  /a/b  matches the  b  element in the XML fragment  <a><b/></a>  because it is a child of the root element  a . It does not have a match in  <b><a/></b>  because in this case,  b  is the root element (and hence the child of no other element). Nor does the XPath expression have a match in  <a><c><b/ ></c></a> ; here,  b  is a descendant of  a , but not actually a child of  a . This construct is extendable to three or more elements. For example, the XPath expression  /a/b/c matches the  c  element in the fragment  <a><b><c/></b></a> . Matches any instance of  < tag > . Example:  //a  matches the  a  element in any of the following:  <a><b><c/></b></a> ;  <c><a><b/></ a></b> ;  <c><b><a/></b></c> . 2251 • / tag1 / tag2 • / tag • // tag Note This function replaces a single portion of a given fragment of XML markup  xml_target  with a new XML fragment  new_xml , and then returns the changed XML. The portion of  xml_target  that is replaced matches an XPath expression  xpath_expr  supplied by the user. mysql>  SELECT ->  UpdateXML(’<a><b>ccc</b><d></d></a>’, ’/a’, ’<e>fff</e>’) AS val1, ->  UpdateXML(’<a><b>ccc</b><d></d></a>’, ’/b’, ’<e>fff</e>’) AS val2, ->  UpdateXML(’<a><b>ccc</b><d></d></a>’, ’//b’, ’<e>fff</e>’) AS val3, ->  UpdateXML(’<a><b>ccc</b><d></d></a>’, ’/a/d’, ’<e>fff</e>’) AS val4, ->  UpdateXML(’<a><d></d><b>ccc</b><d></d></a>’, ’/a/d’, ’<e>fff</e>’) AS val5 ->  \G *************************** 1. row *************************** val1: <e>fff</e> val2: <a><b>ccc</b><d></d></a> val3: <a><e>fff</e><d></d></a> val4: <a><b>ccc</b><e>fff</e></a> val5: <a><d></d><b>ccc</b><d></d></a> • UpdateXML( xml_target ,  xpath_expr ,  new_xml )