定制 edwinhuish/css-to-xpath 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

edwinhuish/css-to-xpath

Composer 安装命令:

composer require edwinhuish/css-to-xpath

包简介

CssToXpath easy way to translate jquery / css selector to Xpath

README 文档

README

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

Example

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

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

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

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]
  • :empty
  • :root
  • :even
  • :odd
  • :first-child
  • :last-child
  • :only-child
  • :parent
  • :first
  • :last
  • :header
  • :not(foo)
  • :has(foo)
  • :contains(foo)

Jquery selector support:

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

统计信息

  • 总下载量: 94
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-02