public function testParseExceptions() { try { CssSelector::toXPath('h1:'); $this->fail('->parse() throws an Exception if the css selector is not valid'); } catch (\Exception $e) { $this->assertInstanceOf('\\Symfony\\Component\\CssSelector\\Exception\\ParseException', $e, '->parse() throws an Exception if the css selector is not valid'); $this->assertEquals("Expected identifier, but <eof at 3> found.", $e->getMessage(), '->parse() throws an Exception if the css selector is not valid'); } }
public function children($query = null) { $children = array(); if (!$this->hasChildren()) { return $children; } if ($query == null) { foreach ($this->childNodes as $child) { if ($child->nodeType == XML_ELEMENT_NODE) { $children[] = $child; } } return $children; } return $this->query(CssSelector::toXPath($query, 'child::')); }
function toXPath($cssExpr, $prefix = 'descendant-or-self::') { return CssSelector::toXPath($cssExpr, $prefix); }
public function find($query) { return $this->xpath()->query(CssSelector::toXPath($query, 'descendant::')); }