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. edwinhuish/css-to-xpath

ActiveLibrary

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 today

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 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

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

2214d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d4ac26d4cd6e8516f3bec4cf57850c4d7c54ede8e26495c7bb0691b3ed254149?d=identicon)[edwinhuish](/maintainers/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

[veewee/xml

XML without worries

1835.9M29](/packages/veewee-xml)[fluentdom/fluentdom

A fluent api for the php dom extension.

337306.9k17](/packages/fluentdom-fluentdom)[atrox/matcher

Powerful XML and HTML matching and data extraction library

9498.1k3](/packages/atrox-matcher)[phpunit/phpunit-dom-assertions

DOM assertions for PHPUnit

29343.5k11](/packages/phpunit-phpunit-dom-assertions)[xparse/element-finder

Elegant data scrapping

3445.0k2](/packages/xparse-element-finder)

PHPackages © 2026

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