class DomQuery extends SimpleXMLElement

Simplifies querying and traversing HTML documents using CSS selectors.

Methods

static DomQuery
fromHtml(string $html)

Creates a DomQuery object from an HTML string.

static DomQuery
fromXml(string $xml)

Creates a DomQuery object from an XML string.

array
find(string $selector)

Returns array of elements matching CSS selector.

bool
has(string $selector)

Checks if any descendant matches CSS selector.

bool
matches(string $selector)

Checks if element matches CSS selector.

DomQuery|null
closest(string $selector)

Returns closest ancestor matching CSS selector.

static string
css2xpath(string $css)

Converts a CSS selector into an XPath expression.

Details

at line 24
static DomQuery fromHtml(string $html)

Creates a DomQuery object from an HTML string.

Parameters

string $html

Return Value

DomQuery

at line 71
static DomQuery fromXml(string $xml)

Creates a DomQuery object from an XML string.

Parameters

string $xml

Return Value

DomQuery

at line 81
array find(string $selector)

Returns array of elements matching CSS selector.

Parameters

string $selector

Return Value

array

at line 99
bool has(string $selector)

Checks if any descendant matches CSS selector.

Parameters

string $selector

Return Value

bool

at line 110
bool matches(string $selector)

Checks if element matches CSS selector.

Parameters

string $selector

Return Value

bool

at line 121
DomQuery|null closest(string $selector)

Returns closest ancestor matching CSS selector.

Parameters

string $selector

Return Value

DomQuery|null

at line 134
static string css2xpath(string $css)

Converts a CSS selector into an XPath expression.

Parameters

string $css

Return Value

string