zend-dom icon indicating copy to clipboard operation
zend-dom copied to clipboard

Support for :last/:last-child and other CSS3 selectors which makes sense

Open aight8 opened this issue 9 years ago • 3 comments

Because it's then configurable without writing custom code

aight8 avatar Jun 23 '16 13:06 aight8

@aight8 Would you be willing to give implementing these features a try?

weierophinney avatar Jun 23 '16 13:06 weierophinney

Hi, i wrote an improved version for my own use. You can find it (and use it in any way) at: https://pastebin.com/Lt4WS2wz

I have tested it with the following conversions (i have not tested all the xpath results):

'a' => '//a', '' => '//', '* > a' => '///a', '#someid' => '//[@id='someid']', 'p#someid' => '//p[@id='someid']', 'p a' => '//p//a', 'p a[href]' => '//p//a[@href]', 'a[href="html"]' => '//a[@href='html']', 'a[href!="html"]' => '//a[@href!='html']', 'a[href*='html']' => '//a[contains(@href, 'html')]', '[href*='html']' => '//[contains(@href, 'html')]', '[href^='html']' => '//[starts-with(@href, 'html')]', '[href$='html']' => '//[@href = substring(@href, string-length(@href) - string-length(@href) +1)]', '[href~='html']' => '//[contains(concat(' ', normalize-space(@href), ' '), ' html ')]', 'p > a' => '//p/a', 'p > a[href]' => '//p/a[@href]', 'p a[href]' => '//p//a[@href]', '> a' => '/a', ':disabled' => '//[@disabled]', '.hidden' => '//[contains(concat(' ', normalize-space(@class), ' '), ' hidden ')]', 'a.hidden[href]' => '//a[contains(concat(' ', normalize-space(@class), ' '), ' hidden ')][@href]', 'a[href] > .hidden' => '//a[@href]/[contains(concat(' ', normalize-space(@class), ' '), ' hidden ')]', 'a:not(b[cool])' => '//a[not(b[@cool])]', 'a:not(.cool)' => '//a[not([contains(concat(' ', normalize-space(@class), ' '), ' cool ')])]', 'a:contains(txt)' => '//a[text()[contains(.,'txt')]]'

Rct567 avatar Apr 23 '17 15:04 Rct567

This repository has been closed and moved to laminas/laminas-dom; a new issue has been opened at https://github.com/laminas/laminas-dom/issues/5.

weierophinney avatar Dec 31 '19 21:12 weierophinney