0

我正在使用 PhpQuery,我需要为另一个标签替换“iframe”

html 文件有一个 iframe

<div id="content">
    <div class="pad3"></div>
        <iframe src="http://www.yahoo.com" id="iFrame"></iframe>
    <div class="pad2"></div>
</div>

穿上这块

$doc = phpQuery::newDocumentFileHTML('file.htm');
$doc->find('iframe')->replaceWith('<p>test</p>');

我期待这个:

<div id="content">
    <div class="pad3"></div>
        <p>test</p>
    <div class="pad2"></div>
</div>

但什么也没有发生。有人可以给我一些线索吗?

此致

4

1 回答 1

0

尝试使用 iframe 元素的 id:

$doc->find('#iFrame')->replaceWith('<p>test</p>');
于 2011-02-16T12:48:52.373 回答