Пример #1
0
 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');
     }
 }
Пример #2
0
 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::'));
 }
Пример #3
0
 function toXPath($cssExpr, $prefix = 'descendant-or-self::')
 {
     return CssSelector::toXPath($cssExpr, $prefix);
 }
Пример #4
0
 public function find($query)
 {
     return $this->xpath()->query(CssSelector::toXPath($query, 'descendant::'));
 }