我有这个带有条件注释的 html 文件。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="css/elements.css">
<title>Page</title>
<!--[if lte IE 6]>
<link rel="stylesheet" type="text/css" href="css/ie6.css" />
<![endif]-->
</head>
etc...
我正在使用 DomDocument 库来修改<link>
属性。有没有办法让DomDocument读取和修改<link>
条件注释中的元素。
foreach($dom->getElementsByTagName('head') as $head) {
foreach($head->childNodes as $node) {
if($node instanceof DOMComment) {
$node->replaceData(16,60,'test');
}
}
}
这段代码有效,我只是让您搜索如何获取replaceData方法的“offset”和“count”值!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)