EVOLUTION-MANAGER
Edit File: css_to_xpath.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Translate a CSS selector to an equivalent XPath expression.</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for css_to_xpath {selectr}"><tr><td>css_to_xpath {selectr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Translate a CSS selector to an equivalent XPath expression. </h2> <h3>Description</h3> <p>This function aims to create an XPath expression equivalent to what would be matched by the given CSS selector. The reason the translation is required is because the XML and xml2 packages, being a libxml2 wrappers, can only evaluate XPath expressions. </p> <p>Using this function, it is possible to search an XML tree without the prerequisite of knowing XPath. </p> <h3>Usage</h3> <pre> css_to_xpath(selector, prefix = "descendant-or-self::", translator = "generic") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>selector</code></td> <td> <p>A character vector of CSS selectors. </p> </td></tr> <tr valign="top"><td><code>prefix</code></td> <td> <p>The prefixes to apply to the resulting XPath expressions. The default or <code>""</code> are most commonly used. </p> </td></tr> <tr valign="top"><td><code>translator</code></td> <td> <p>The type of translator that will be used. Possible options are <code>generic</code> (the default), or <code>html</code> or <code>xhtml</code>. </p> </td></tr> </table> <h3>Details</h3> <p>Each selector given to this function will be translated to an equivalent XPath expression. The resulting XPath expression can be given a prefix which determines the scope of the expression. The default prefix determines the scope to be the node itself and all descendants of the node. Most commonly the prefix is either the default or <code>""</code>, unless it is known what scope a particular XPath expression should have. </p> <p>The translator used is usually unnecessary to specify as the default is sufficient for most cases. However, it is of use when creating expressions relating to (X)HTML pseudo elements and languages. In particular it qualifies the following pseudo selectors to apply only to relevant (X)HTML elements: <code>:checked</code>, <code>:disabled</code>, <code>:enabled</code> and <code>:link</code>. </p> <p>When the translator is set to <code>html</code>, all elements and attributes will be converted to lower case. This restriction is removed when the translator is <code>xhtml</code> (or the default <code>generic</code> translator). </p> <h3>Value</h3> <p>A character vector of XPath expressions. </p> <h3>Author(s)</h3> <p>Simon Potter </p> <h3>References</h3> <p>CSS3 Selectors <a href="https://www.w3.org/TR/css3-selectors/">https://www.w3.org/TR/css3-selectors/</a>, XPath <a href="https://www.w3.org/TR/xpath/">https://www.w3.org/TR/xpath/</a>. </p> <h3>Examples</h3> <pre> css_to_xpath(".testclass") css_to_xpath("#testid", prefix = "") css_to_xpath("#testid .testclass") css_to_xpath(":checked", translator = "html") </pre> <hr /><div style="text-align: center;">[Package <em>selectr</em> version 0.4-2 <a href="00Index.html">Index</a>]</div> </body></html>