Simple wrapper function that returns an element by the
id.
public getElementById ( string $id ) : |
||
$id | string | |
return |
public function testConfigStrict() { $dom = new Dom(); $dom->setOptions(['strict' => true]); $dom->load('<div><p id="hey">Hey you</p> <p id="ya">Ya you!</p></div>'); $this->assertEquals(' ', $dom->getElementById('hey')->nextSibling()->text); }
public function testConfigLocalOverride() { $dom = new Dom(); $dom->setOptions(['whitespaceTextNode' => false]); $dom->load('<div><p id="hey">Hey you</p> <p id="ya">Ya you!</p></div>', ['whitespaceTextNode' => true]); $this->assertEquals(' ', $dom->getElementById('hey')->nextSibling()->text); }
public function testGetElementById() { $dom = new Dom(); $dom->load('<div class="all"><p>Hey bro, <a href="google.com" id="78">click here</a></div><br />'); $this->assertEquals('<a href="google.com" id="78">click here</a>', $dom->getElementById('78')->outerHtml); }