title: xml processing in mysql
body: <p>I have an <code>xml</code> persisted in database something as follows:</p>
  
  <pre><code>&lt;root available-locales="en_US" default-locale="en_US"&gt;
      &lt;dynamic-element name="fdemo-redirect-url" repeatable="false" dataType="string" indexType="" required="false" showLabel="true" type="text" width="25"&gt;
          &lt;meta-data locale="en_US"&gt;
              &lt;entry name="label"&gt;&lt;![CDATA[fdemo-redirect-url]]&gt;&lt;/entry&gt;
          &lt;/meta-data&gt;
      &lt;/dynamic-element&gt;
      &lt;dynamic-element name="close_button" repeatable="false" dataType="document-library" indexType="" required="false" showLabel="true" type="ddm-documentlibrary" fieldNamespace="ddm"&gt;
          &lt;meta-data locale="en_US"&gt;
              &lt;entry name="label"&gt;&lt;![CDATA[close_button]]&gt;&lt;/entry&gt;
          &lt;/meta-data&gt;
      &lt;/dynamic-element&gt;
  
  
  ....
  </code></pre>
  
  <p>I need to write a query which should replace an hyphen in <code>name</code> attribute of <code>dynamic-element</code> tag whose <code>dataType</code> attribute is <code>html</code>. I ended up creating the following query. But this works only for one tag at a time. I do not want to loop it using a procedure. Is there a way to tweak this query in such a way that this works for multiple <code>dynamic-element</code> tags?</p>
  
  <pre><code> UPDATE table_name 
        SET xsd = UpdateXML(
             xsd,
             '//dynamic-element[5]/@name', 
              CONCAT(
                  'name="', 
                  REPLACE(ExtractValue(xsd, '//dynamic-element[5]/@name'), '-', '_'), 
                  '"')) 
        WHERE ExtractValue(xsd, '//dynamic-element[5]/@dataType') = 'html';
  </code></pre>
  
  <p>Here in this above query only 5th <code>dynamic-element</code> tag is handled for all the rows.</p>