PHP-HTMLDOM解析-在<;视频>;标签
我喜欢将htmlPHP-HTMLDOM解析-在<;视频>;标签,php,html,parsing,dom,Php,Html,Parsing,Dom,我喜欢将html转换为amp,如果使用的浏览器不支持HTML5,我的问题是回退文本 <video width="320" height="240" controls> <source src="movie.mp4" type="video/mp4"> <source src="movie.ogg" type="video/ogg"> Your browser does not support the video tag. </video>
转换为amp
,如果使用的浏览器不支持HTML5,我的问题是回退文本
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
有什么想法吗
安德烈亚斯我找到了这个,它成功了。演示:但是你需要做一些工作来完成你需要做的。@alistaircol:对不起,你不明白我的问题。。。我想用div和p标记包围回退文本,正如您在amp视频示例中看到的那样……我发现了这个,它起了作用。演示:但是你需要做一些工作来完成你需要做的。@alistaircol:对不起,你不明白我的问题。。。我想用div和p标记包围回退文本,正如您在amp视频示例中看到的那样。。。
<amp-video width=320 height=240 src="https://yourhost.com/videos/movie.mp4"
poster="movie-poster.jpg">
<source type="video/mp4" src="movie.mp4">
<source type="video/ogg" src="movie.ogg">
<div fallback><p>
Your browser doesn’t support HTML5 video
</p></div>
</amp-video>
<?php
$html = '<video width="320" height="240" controls><source src="movie.mp4" type="video/mp4"><source src="movie.ogg" type="video/ogg">Your browser does not support the video tag.</video>';
$dom = new DOMDocument;
$dom->loadHTML($html);
$checks = $dom->getElementsByTagName('video');
if ($checks != '') {
foreach ($checks as $check) {
echo $check->textContent;
}
}
?>
<?php
$html = '<video width="320" height="240" controls><source src="movie.mp4" type="video/mp4"><source src="movie.ogg" type="video/ogg">Your browser does not support the video tag.</video>';
$dom = new DOMDocument;
libxml_use_internal_errors(true);
$dom->loadHTML($html);
libxml_clear_errors();
$checks = $dom->getElementsByTagName('video');
if ($checks != '') {
foreach ($checks as $check) {
$newdoc = new DOMDocument();
$cloned = $check->cloneNode(TRUE);
$newdoc->appendChild($newdoc->importNode($cloned,TRUE));
$fallback = $newdoc->saveHTML();
$fallbacktext = strip_tags($fallback);
echo $fallbacktext;
echo $fallback;
//$fallbacktext = "Your browser does not support the video tag.";
echo str_replace($fallbacktext,'hello',$fallback);
}
}
$html = $dom->saveHTML();
//echo $html;
?>