DiDom\Element::createBySelector PHP Method

createBySelector() public static method

Create new element node by CSS selector.
public static createBySelector ( string $selector, string $value = null, array $attributes = [] ) : Element
$selector string
$value string
$attributes array
return Element
    public static function createBySelector($selector, $value = null, $attributes = [])
    {
        return Document::create()->createElementBySelector($selector, $value, $attributes);
    }

Usage Example

示例#1
0
 public function testCreateBySelector()
 {
     $element = Element::createBySelector('li.item.active', 'Foo', ['data-id' => 1]);
     $this->assertEquals('li', $element->tag);
     $this->assertEquals('Foo', $element->text());
     $this->assertEquals(['class' => 'item active', 'data-id' => 1], $element->attributes());
 }