开发者

PhpQuery and replaceWith, How to?

I'm using PhpQuery and I need to replace an "iframe" for another tag

The html file have an Iframe

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

Whit this piece of

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

I 开发者_如何学编程expected this:

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

But nothing happens. Can someone give me some clues?

Best Regards


Try using the id of your iframe element:

$doc->find('#iFrame')->replaceWith('<p>test</p>');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜