Class

Symfony\Component\CssSelector\XPathExpr

class XPathExpr

XPathExpr represents an XPath expression.

This component is a port of the Python lxml library, which is copyright Infrae and distributed under the BSD license.

Methods

__construct(string $prefix = null, string $path = null, string $element = '*', string $condition = null, Boolean $starPrefix = false)

Constructor.

string getPrefix()

Gets the prefix of this XPath expression.

string getPath()

Gets the path of this XPath expression.

Boolean hasStarPrefix()

Answers whether this XPath expression has a star prefix.

string getElement()

Gets the element of this XPath expression.

string getCondition()

Gets the condition of this XPath expression.

string __toString()

Gets a string representation for this XPath expression.

addCondition(string $condition)

Adds a condition to this XPath expression.

addPrefix(string $prefix)

Adds a prefix to this XPath expression.

addNameTest()

Adds a condition to this XPath expression using the name of the element as the desired value.

addStarPrefix()

Adds a star prefix to this XPath expression.

join(string $combiner, XPathExpr $other)

Joins this XPath expression with $other (another XPath expression) using $combiner to join them.

static string xpathLiteral(mixed $s)

Gets an XPath literal for $s.

Details

at line 39
public __construct(string $prefix = null, string $path = null, string $element = '*', string $condition = null, Boolean $starPrefix = false)

Constructor.

Parameters

string $prefix Prefix for the XPath expression.
string $path Actual path of the expression.
string $element The element in the expression.
string $condition A condition for the expression.
Boolean $starPrefix Indicates whether to use a star prefix.

at line 53
public string getPrefix()

Gets the prefix of this XPath expression.

Return Value

string

at line 63
public string getPath()

Gets the path of this XPath expression.

Return Value

string

at line 73
public Boolean hasStarPrefix()

Answers whether this XPath expression has a star prefix.

Return Value

Boolean

at line 83
public string getElement()

Gets the element of this XPath expression.

Return Value

string

at line 93
public string getCondition()

Gets the condition of this XPath expression.

Return Value

string

at line 103
public string __toString()

Gets a string representation for this XPath expression.

Return Value

string

at line 129
public addCondition(string $condition)

Adds a condition to this XPath expression.

Any pre-existent condition will be ANDed to it.

Parameters

string $condition The condition to add.

at line 144
public addPrefix(string $prefix)

Adds a prefix to this XPath expression.

It will be prepended to any pre-existent prefixes.

Parameters

string $prefix The prefix to add.

at line 158
public addNameTest()

Adds a condition to this XPath expression using the name of the element as the desired value.

This method resets the element to '*'.

at line 174
public addStarPrefix()

Adds a star prefix to this XPath expression.

This method will prepend a '*' to the path and set the star prefix flag to true.

at line 197
public join(string $combiner, XPathExpr $other)

Joins this XPath expression with $other (another XPath expression) using $combiner to join them.

Parameters

string $combiner The combiner string.
XPathExpr $other The other XPath expression to combine with this one.

at line 222
static public string xpathLiteral(mixed $s)

Gets an XPath literal for $s.

Parameters

mixed $s Can either be a Node\ElementNode or a string.

Return Value

string