query($query); $allowed_attributes = ['class', 'id']; foreach ($entries as $tag) { $div = $doc->createElement('div'); $br = $doc->createElement('br'); foreach ($allowed_attributes as $attribute) { if ($tag->hasAttribute($attribute)) { $div->setAttribute($attribute, $tag->getAttribute($attribute)); } } if ($tag->hasChildNodes()) { foreach ($tag->childNodes as $node) { $ch = $node->cloneNode(true); if( $ch->nodeName == 'div' && $ch->getAttribute('id') == 'inject'){ //$div->removeChild($ch); }else{ $div->appendChild( $ch ); } } } $tag->parentNode->replaceChild($div, $tag); }*/ $ahrefs = $doc->getElementsByTagName('span'); foreach($ahrefs as $element){ for ( $k = $element->attributes->length - 1; $k >= 0; --$k) { if( $element->attributes->item($k)->nodeName != 'id' && $element->attributes->item($k)->nodeName != 'class' ){ $element->removeAttributeNode( $element->attributes->item($k)); } } } return $doc; } public function getNecessaryScripts() { return $this->necessary_scripts; } }