TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Jan 2016 |
Maintained by Francis Chong.
Depends on: | |
CocoaLumberjack | ~> 2.0.0 |
NUIParse | >= 0 |
A CSS Selector to XPath Selector for Objective-C. Support mostly used subset of CSS Selector Level 3.
I build this converter so that I can use .class
instead of //*[contains(concat(' ', normalize-space(@class), ' '), ' class ')]
in IGHTMLQuery.
#import "CSSSelectorConverter.h"
CSSSelectorToXPathConverter* converter = [[CSSSelectorToXPathConverter alloc] init];
[converter xpathWithCSS:@"p" error:nil];
// => "//p"
[converter xpathWithCSS:@"p.intro" error:nil];
// => "//p[contains(concat(' ', normalize-space(@class), ' '), ' intro ')]"
It supports following CSS Selectors:
* "//*"
p "//p"
p.intro "//p[contains(concat(' ', normalize-space(@class), ' '), ' intro ')]"
p#apple "//p[@id = 'apple']"
p * "//p//*"
p > * "//p/*"
H1 + P "//H1/following-sibling::*[1]/self::P"
H1 ~ P "//H1/following-sibling::P"
ul, ol "//ul | //ol"
p[align] "//p[@align]"
p[class~="intro"] "//p[contains(concat(\" \", @class, \" \"),concat(\" \", 'intro', \" \"))]"
div[att|="val"] "//div[@att = \"val\" or starts-with(@att, concat(\"val\", '-'))]"
It supports following pseduo classes:
Currently pseduo classes with parameters are not supported (I probably will not implement them until I really NEEDS them):
Following pseduo classes will not be supported:
pod install
MIT License. See License.txt.