public function testMultipleSingleQuotes() { $dom = new Dom(); $dom->load("<a title='Ain't this the best' href=\"http://www.example.com\">Hello</a>"); $this->assertEquals("Ain't this the best", $dom->getElementsByTag('a')[0]->title); }
public function testGetElementsByTag() { $dom = new Dom(); $dom->load('<div class="all"><p>Hey bro, <a href="google.com" id="78">click here</a></div><br />'); $this->assertEquals('<p>Hey bro, <a href="google.com" id="78">click here</a></p>', $dom->getElementsByTag('p')[0]->outerHtml); }
public function testChangeContent() { $dom = new Dom(); $dom->load('<div class="all"><p>Hey bro, <a href="google.com" id="78">click here</a></div><br />'); $links = $dom->find('a'); $links[0]->setInnerHtml('gogogo'); $this->assertEquals('<p>Hey bro, <a href="google.com" id="78">gogogo</a></p>', $dom->getElementsByTag('p')[0]->outerHtml); }
public function testScriptCleanerScriptTag() { $dom = new Dom(); $dom->load(' <p>.....</p> <script> Some code ... document.write("<script src=\'some script\'><\\/script>") Some code ... </script> <p>....</p>'); $this->assertEquals('....', $dom->getElementsByTag('p')[1]->innerHtml); }
public function getDescription() { $intro = $this->dom->getElementById('intro'); $dom = new Dom(); $dom->load($intro); $p = $dom->getElementsByTag('p'); if (count($p) > 1) { return htmlentities($p[1]); } return htmlentities($p); }