开发者

PhpQuery and replaceWith, How to?

开发者 https://www.devze.com 2023-02-11 14:13 出处:网络
I\'m using PhpQuery and I need to replace an \"iframe\" for another tag The html file have an Iframe <div id=\"content\">

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

精彩评论

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

关注公众号