xpath() public method

Searches for an node in the DOM tree for a given XPath expression.
public xpath ( string $expression, boolean $wrapElement = true ) : Element[] | DOMElement[]
$expression string XPath expression
$wrapElement boolean Returns array of \DiDom\Element if true, otherwise array of \DOMElement
return Element[] | DOMElement[]
Example #1
0
 public function testXpath()
 {
     $html = $this->loadFixture('posts.html');
     $document = new Document($html, false);
     $elements = $document->xpath("//*[contains(concat(' ', normalize-space(@class), ' '), ' post ')]");
     $this->assertTrue(is_array($elements));
     $this->assertEquals(3, count($elements));
 }