Ejemplo n.º 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');
     }
 }
Ejemplo n.º 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::'));
 }
Ejemplo n.º 3
0
 function toXPath($cssExpr, $prefix = 'descendant-or-self::')
 {
     return CssSelector::toXPath($cssExpr, $prefix);
 }
Ejemplo n.º 4
0
 public function find($query)
 {
     return $this->xpath()->query(CssSelector::toXPath($query, 'descendant::'));
 }