getElementsByTag() public method

Simple wrapper function that returns all elements by tag name.
public getElementsByTag ( string $name ) : array
$name string
return array
Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
 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);
 }