示例#1
0
文件: Tag.php 项目: aduroo/feed-api
 /**
  * Remove script tags.
  *
  * @param string $data Input data
  *
  * @return string
  */
 public function removeBlacklistedTags($data)
 {
     $dom = XmlParser::getDomDocument($data);
     if ($dom === false) {
         return '';
     }
     $xpath = new DOMXpath($dom);
     $nodes = $xpath->query(implode(' | ', $this->tag_blacklist));
     foreach ($nodes as $node) {
         $node->parentNode->removeChild($node);
     }
     return $dom->saveXML();
 }
示例#2
0
 /**
  * Strip useless tags.
  *
  * @param string $content
  *
  * @return string
  */
 public function stripGarbage($content)
 {
     $dom = XmlParser::getDomDocument($content);
     if ($dom !== false) {
         $xpath = new DOMXPath($dom);
         $this->stripTags($xpath);
         $this->stripAttributes($dom, $xpath);
         $content = $dom->saveXML($dom->documentElement);
     }
     return $content;
 }