Coder Social home page Coder Social logo

css2xpath's Introduction

CSS2XPath

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

Build Status Latest Stable Version

Example

$translator = new TheSeer\CSS2XPath\Translator();

// Will output //*[contains(concat(" ",normalize-space(@class)," ")," note ")]
echo $translator->translate('.note');

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

Installation

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

composer require theseer/css2xpath

Selectors supported

The following selectors are currently covered:

  • #id
  • tag#id
  • tag #id
  • tag
  • tag tag
  • tag > tag
  • tag + tag
  • tag ~ tag
  • tag, tag
  • .classname
  • tag.classname
  • tag .classname
  • tag.classname, tag.classname
  • tag.classname tag.classname
  • tag.classname > tag.classname
  • tag#id + tag > 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]
  • tag:enabled
  • tag:checked
  • tag:disabled
  • :empty
  • :root

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.