0
私のWebページに第三者iframe
を読み込んで変更して出力する必要があります。提案したように、私は単にとそのsrc
属性を含む中間ページを作成しました。DOMxpathクエリで何も返されません
ページを出力するPHPコードは次のようになります。
$iframe->loadHTML(file_get_contents("http://example.com/iframe_page.php")); //creating DOM object, see htm content below
$xpathObj= new DOMXPath($iframe);//creating DOMXPath object
foreach ($xpathObj->query('//div[@id="specific_id"]') as $node){ //this query returns nothing
$node->parentNode->removeChild($node);//i need to remove the div with that id, but there is nothing to remove
}
echo $iframe->saveHTML($iframe->documentElement);//the iframe output works fine
そして、私のiframe
の内容は、次のようなものになります。私もどうかを確認するためにJSを無効にすることを試みた
<html>
<head>
</head>
<body>
<div>
<div>
<div id="specific_id">
</div>
</div>
</div>
</body>
</html>
をこのdivは、フロントエンドのコードで配置され、JSはドキュメントの構造が全く同じに見えないようにすることはできません。
この「html」コンテンツをお持ちですか?あなたのコードは正常に動作しているので.. –
あなたのコードが動作していることを確認してくださいhttps://eval.in/785036 –
@SahilGulati確かに、その構造はとにかく...ここで他に何ができるのでしょうか? – RWS