脚本宝典收集整理的这篇文章主要介绍了php domdocument创建自我关闭标记,打破html,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<iframe tITle="YouTube video player" width="640" height="370" src="http://www.youtube.COM/embed/*id*" frameborder="0" allowfullscreen></iframe>
然后通过DOMdocument()解析文本,该文件将上述内容转换为自闭标签:
<iframe class="EmbeddedVideo" title="YouTube video player" width="640" height="370" src="http://www.youtube.com/embed/xp4HhaUMB3I" frameborder="0" allowfullscreen=""/>
这打破了Chrome和& ;;歌剧.如果我手动将htML更改回:
<iframe class="EmbeddedVideo" title="YouTube video player" width="640" height="370" src="http://www.youtube.com/embed/xP4HhaUMB3I" frameborder="0" allowfullscreen=""></iframe>
有用.
首先,自闭标签有什么问题(因为我看不到任何东西)?
有没有办法强制domdocument()使用’正确’的结束标记?
LIBXML_NOEMPTYTAG
:
$doc->saveXML($node,LIBXML_NOEMPTYTAG);
这将强制扩展< iframe />到< iframe>< / iframe>
但是,您也可以使用savehtml()(首选).这将正确保留HTML标记:
$doc->saveHTML();
以上是脚本宝典为你收集整理的php domdocument创建自我关闭标记,打破html全部内容,希望文章能够帮你解决php domdocument创建自我关闭标记,打破html所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。