I've recently had serious grief from XML namespaces and dealing with them effectively in PHP. Here's a sample of the worst kind of culprit:
<dc:type xsi:type="TypeName" xsi:identifier="NN">Others</dc:type>
What I successfully managed to do using preg_replace was to "un-namespace" the tags (without breaking URLs) using:
$xml = preg_replace(
'/<(\/?)([^:" ].*):([^>\/ ].*)(\/?)>/msiU',
'<$1$2_$3$4>',
$x->readOuterXML()
);
# <dc_type xsi:type="TypeName" xsi:identifier="NN">Others</dc_type>
What I couldn't do - through lack of regular expression wizardry - was convert all namespaced attributes into the same format. I managed to convert the first occurence, but don't know how to set a repeatable condition. I deleted the code because it didn't work (and I can't remember what I did), but the result was like this:
<dc_type xsi_type="TypeName" xsi:identifier="NN">Others</dc_type>
Whereas what would be beautiful is this:
<dc_type xsi_type="TypeName" xsi_identifier="NN">Others</dc_type>
Are there any regex masters out there who can help?