PHPackages                             edwinhuish/css-to-xpath - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. edwinhuish/css-to-xpath

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

edwinhuish/css-to-xpath
=======================

CssToXpath easy way to translate jquery / css selector to Xpath

v1.0.5(6y ago)1941MITPHPPHP ^7.0.0CI failing

Since Apr 2Pushed 6y ago1 watchersCompare

[ Source](https://github.com/edwinhuish/CssToXpath)[ Packagist](https://packagist.org/packages/edwinhuish/css-to-xpath)[ RSS](/packages/edwinhuish-css-to-xpath/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (7)Used By (1)

CssToPath
=========

[](#csstopath)

This is a library to translate various CSS selectors to their XPath equivalent.

Example
-------

[](#example)

```
// Will output //*[contains(concat(' ', normalize-space(@class), ' '), ' node ')]
echo CssToXpath::transform('.node');

// Will output //*[@id='someid']
echo $translator->translate('#someid');
```

Installation
------------

[](#installation)

You can add this library as a local, per-project dependency to your project using Composer:

```
composer require edwinhuish/css-to-xpath

```

Selectors supported
-------------------

[](#selectors-supported)

The following selectors are currently covered:

- \#id
- tag#id
- tag #id
- tag
- tag tag
- tag &gt; tag
- tag + tag
- tag ~ tag
- tag, tag
- .classname
- tag.classname
- tag .classname
- tag.classname, tag.classname
- tag.classname tag.classname
- tag.classname &gt; tag.classname
- tag#id + tag &gt; tag
- tag\[id\]:contains(Selectors)
- tag\[attribute\]\[attribute\]
- tag\[attribute\]
- tag\[attribute=example\]
- tag\[attribute^=exa\]
- tag\[class$=mple\]
- tag\[attribute\*=e\]
- tag\[attribute|=dialog\]
- tag\[attribute!=made\_up\]
- tag\[attribute!="made\_up"\]
- tag\[attribute~=example\]
- tag:not(.classname)
- tag:contains(selectors)
- tag:nth-child(n)
- tag:nth-child(even)
- tag:nth-child(odd)
- tag:nth-child(3n+8)
- tag:nth-child(2n+1)
- tag:nth-child(3)
- tag:nth-child(4n)
- tag:only-child
- tag:last-child
- tag:first-child
- foo|bar
- tag\[attribute^=exa\]\[attribute$=mple\]
- :empty
- :root
- :even
- :odd
- :first-child
- :last-child
- :only-child
- :parent
- :first
- :last
- :header
- :not(foo)
- :has(foo)
- :contains(foo)

Jquery selector support:
------------------------

[](#jquery-selector-support)

- :eq(2)
- :eq(-5)
- :gt(4)
- :lt(8)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

6

Last Release

2268d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5207925?v=4)[Edwin Hui](/maintainers/edwinhuish)[@edwinhuish](https://github.com/edwinhuish)

---

Top Contributors

[![edwinhuish](https://avatars.githubusercontent.com/u/5207925?v=4)](https://github.com/edwinhuish "edwinhuish (7 commits)")

---

Tags

cssselectortransformtranslatorxpathXpathcss-selectorcss selector to xpathjquery selectorjquery selector to xpath

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/edwinhuish-css-to-xpath/health.svg)

```
[![Health](https://phpackages.com/badges/edwinhuish-css-to-xpath/health.svg)](https://phpackages.com/packages/edwinhuish-css-to-xpath)
```

###  Alternatives

[appzcoder/lumen-routes-list

Display the route list of Lumen

119735.8k1](/packages/appzcoder-lumen-routes-list)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
