服务器端css选择器 [英] server-side css selectors
问题描述
我创建了一个工具,它将检查动态生成的XHTML并根据预期内容进行验证。
I am creating a tool that will check dynamically generated XHTML and validate it against expected contents.
我需要确认结构是否正确,匹配。可能还有其他我不感兴趣的属性,所以一个直接的字符串比较是不合适的。
I need to confirm the structure is correct and that specific attributes exist/match. There may be other attributes which I'm not interested in, so a direct string comparison is not suitable.
一种验证方法是使用XPath,这已经,但我也想更少的冗长 - 我想能够使用CSS选择器,像我可以用jQuery,但在服务器上 - 在CFML代码,而不是在客户端。
One way of validating this is with XPath, and I have implemented this already, but I would also like something less verbose - I want to be able to use CSS Selectors, like I can with jQuery, but on the server - within CFML code - as opposed to on the client.
是否有一个CFML或Java库允许我对一个XHTML字符串使用CSS选择器?
推荐答案
我刚刚发布了一个开源项目,这是Java中的W3C CSS选择器3级实现。请试试。我正在寻找同样的事情,并决定实现我自己的引擎。它受到WebKit等代码的启发。
I've just released an open source project which is a W3C CSS Selectors Level 3 implementation in Java. Please give it a try. I was looking for the same thing and decided to implement my own engine. It's inspired by the code in WebKit etc.
http://github.com/chrsan/css-selectors/tree
这篇关于服务器端css选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!