服务器端 CSS 选择器 [英] server-side css selectors

查看:22
本文介绍了服务器端 CSS 选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个工具,它将检查动态生成的 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 Selectors Level 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆