PHP DomDocument alter conditional comments

前端 未结 1 1682
青春惊慌失措
青春惊慌失措 2021-01-19 10:44

I have this html file with a conditional comment.


    
        

        
相关标签:
1条回答
  • 2021-01-19 11:07
    foreach($dom->getElementsByTagName('head') as $head) {
        foreach($head->childNodes as $node) {
            if($node instanceof DOMComment) {
                $node->replaceData(16,60,'test');
            }
        }
    }
    

    This code works, I just let you search how to get 'offset' and 'count' value for the replaceData method !

    0 讨论(0)
提交回复
热议问题