PHP DomDocument alter条件注释

PHP DomDocument alter条件注释,php,html,dom,document,Php,Html,Dom,Document,我有一个带有条件注释的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">

我有一个带有条件注释的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库修改
属性。有没有办法让DomDocument读取和修改条件注释中的
元素

foreach($dom->getElementsByTagName('head') as $head) {
    foreach($head->childNodes as $node) {
        if($node instanceof DOMComment) {
            $node->replaceData(16,60,'test');
        }
    }
}

这段代码很有效,我只是让您搜索如何获取replaceData方法的“offset”和“count”值

令人难以置信的是,我在网上什么都找不到!我希望它能帮助其他人^^有没有办法让getElementsByTagName也在评论中找到标记?循环遍历所有子节点以查找注释中的子节点并不理想。