开发者

Is there a CSS object model or CSS querying api for .net?

开发者 https://www.devze.com 2023-03-22 21:26 出处:网络
Is there a library out there that will allow me to write the following kind of code, which parses CSS and returns a queryable object model

Is there a library out there that will allow me to write the following kind of code, which parses CSS and returns a queryable object model

string input = "p, span { font-family: arial; }";
var cssRules = new Parser().Parse(input);
var rule = cssRules.Find(new Selector("p")).First();

Assert.That(rule.Attribute("font-family").Value, Is.Equal.To("arial"));

I've taken a look at dotless, downloaded their code and examined some of the relevant unit tests and fixtures. I开发者_如何学编程t looks promising but I can't quite work out how to use it to parse and query plain CSS.


The closest I know is CssParser from jsonfx.net:

http://css-parser.googlecode.com/svn/trunk/CssParser/

You can parse any css and browse through selectors afterwards using StyleSheet property of CssParser

0

精彩评论

暂无评论...
验证码 换一张
取 消