xpath를 사용하여 헤더의 스타일 시트 <link>
의 href
인 스타일 시트를 변경합니다.PHP 스타일 시트를 변경하는 XPath
하지만 전혀 작동하지 않습니다.
$html=file_get_contents('http://stackoverflow.com');
$doc = new DOMDocument();
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
$css_links = $xpath->evaluate("//link[@type='text/css']");
for ($i = 0; $i < $css_links->length; $i++)
{
$csslink = $css_links->item($i);
$oldurl = $csslink->getAttribute('href');
$newURL='http://example.com/aaaa.css';
$csslink->removeAttribute('href');
$csslink->setAttribute('href', $newURL);
}
echo $html;
가 [fopen을 래퍼]가 :
또한
foreach
DOMNodeList implements Traversable
때문으로for($i...)
을 대체 할 수 url-fopen) 외부 소스에서 콘텐츠를 가져올 수 있습니까? 왜 @ -notation을 사용하여 오류 메시지를 표시하지 않습니까? 어쩌면 당신의 대답이있을 것입니다. – Mamuz@ mamuz, 네, phpinfo에 따르면 – werva