- explode: documentation ( source)
<?php
$xml = '<products><product><features><feature>Dimensions:300x1220x12:8</feature><feature>Weight:25kg:853</feature></features></product></products>';
$doc = new DOMDocument('1.0', 'UTF-8');
$doc->loadXML($xml);
foreach($doc->getElementsByTagName('feature') as $featureNode) {
$values = explode(':', $featureNode->textContent);
$newNode = $doc->createElement($values[0]);
$newNode->appendChild($doc->createTextNode($values[1]));
$featureNode->removeChild($featureNode->firstChild);
$featureNode->appendChild($newNode);
}
$doc->formatOutput = true;
echo $doc->saveXML();