I get a page using file_get_contents
from a remote server, but I want to filter that page and get a DIV from it that has class "text" using PHP. I started with DOMDocument
but I'm lost now.
Herhangi bir yardım?
$file = file_get_contents("xx");
$elements = new DOMDocument();
$elements->loadHTML($file);
foreach ($elements as $element) {
if( !is_null($element->attributes)) {
foreach ($element->attributes as $attrName => $attrNode) {
if( $attrName == "class" && $attrNode== "text") {
echo $element;
}
}
}
}