PhpQuery and replaceWith, How to?

1k views Asked by At

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

1

There are 1 answers

0
Luciano On

Try using the id of your iframe element:

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