У меня есть объект DOM с загруженной разметкой HTML. Я пытаюсь заменить все теги встраивания, которые выглядят так:
<embed allowfullscreen="true" height="200" src="path/to/video/1.flv" width="320"></embed>
С тегом, подобным этому:
<a
href="path/to/video/1.flv"
style="display:block;width:320px;height:200px;"
id="player">
</a>
У меня возникают проблемы с этим, и я не хочу использовать регулярное выражение для этого. Не могли бы вы мне помочь?
EDIT:
Это то, что у меня есть до сих пор:
// DOM initialized above, not important
foreach ($dom->getElementsByTagName('embed') as $e) {
$path = $e->getAttribute('src');
$width = $e->getAttribute('width') . 'px';
$height = $e->getAttribute('height') . 'px';
$a = $dom->createElement('a', '');
$a->setAttribute('href', $path);
$a->setAttribute('style', "display:block;width:$width;height:$height;");
$a->setAttribute('id', 'player');
$dom->replaceChild($e, $a); // this line doesn't work
}