<?php
$raw_html = <<<EOF
<p>
Some text here <strong class="wanna-attributes-too">with strong element!</strong>.
But there can be even <b>bold</b> tag and many others.
</p>
EOF;
$dom = new DOMDocument();
$dom->loadHTML($raw_html);
$html = simplexml_import_dom($dom);
echo $html->asXML();
<html><body><p>
Some text here <strong class="wanna-attributes-too">with strong element!</strong>.
But there can be even <b>bold</b> tag and many others.
</p></body></html>
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
<html>
<body>
<p>
Some text here <strong class="wanna-attributes-too">with strong element!</strong>.
But there can be even <b>bold</b> tag and many others.
</p>
</body>
</html>