sql to update an xml attribute (mysql)

vinnythetiger

New Member
In an data load, it seems some xml attributes mapped incorrectly and i'm now trying to correct this, but am struggling with mysql's handling of this xml column.I want to correct the xml attributes (Not Values) for all occurrences of a field (with attribute 'tag="520"') with subfield (with attribute 'code="3"'). The query below returns 0 rows affected, 1 rows found. Any clues as to how to achieve this.\[code\]UPDATE biblioitemsSET marcxml = UpdateXML(marcxml,'datafield[@tag="520"]/subfield[@code="3"]', 'datafield[@tag="520"][@ind1="3"]/subfield[@code="a"]')WHERE biblionumber = '220405';\[/code\]XML Fragment included for clarity:Original Fragment\[code\]<datafield tag="300" ind1=" " ind2=" "> <subfield code="f">article</subfield></datafield><datafield tag="520" ind1=" " ind2=" "> <subfield code="3">A description of something here</subfield></datafield><datafield tag="655" ind1=" " ind2=" "> <subfield code="a"></subfield></datafield>\[/code\]What I want as the result:\[code\]<datafield tag="300" ind1=" " ind2=" "> <subfield code="f">article</subfield></datafield><datafield tag="520" ind1="3" ind2=" "> <subfield code="a">A description of something here</subfield></datafield><datafield tag="655" ind1=" " ind2=" "> <subfield code="a"></subfield></datafield>\[/code\]Couldn't work out how to highlight the change in a code block (it's the ind1 attribute in the tag="520" datafield and it's associated subfield attributes)
 
Back
Top