Re: XPath and find/findAll methods

On 11/22/11 7:31 AM, Martin Kadlec (BS-Harou) wrote:
> CSS: "article>  div:nth-child(2) input[type=text], article>  div:nth-child(2) input:not([type]), article>  div:nth-child(2) input[type=color]";
> XPath: "//article/div[2]//input[@type='text' | @type='color'| not(@type)]";

How about:

CSS:

   "article > div:nth-child(2) input:any([type=text], :not([type]), 
[type=color])"

(modulo the continuing bikeshedding about calling it :any vs :matches)? 
  I fully expect this to be available before any sort of XPath changes 
in UAs.

> 2) It's impossible to write the CSS selector (or really really hard/long)
> a - "*[@data-price>30]";
> b - "*[position()<30]";
> c - "div[@*]";
> d - "//div[parent::*//a]";

Indeed.  This seems to be the primary use case for XPath.

-Boris

Received on Tuesday, 22 November 2011 13:08:38 UTC