我有一个带条件注释的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>元素。
发布于 2010-10-07 16:01:13
foreach($dom->getElementsByTagName('head') as $head) {
foreach($head->childNodes as $node) {
if($node instanceof DOMComment) {
$node->replaceData(16,60,'test');
}
}
}这段代码可以工作,我只是让你搜索如何为replaceData方法获取'offset‘和'count’值!
https://stackoverflow.com/questions/3879108
复制相似问题