jStyleParser是一个开源Java的CSS解析器,可以在Java程序中解析CSS样式文件。
Mave
<depedecy> <groupId>et.sf.cssbox</groupId> <artifactId>jstyleparser</artifactId> <versio>3.2</versio></depedecy>示例代码:
//get the elemet styleStyleMap map = CSSFactory.assigDOM(doc, ecodig, base, medium, true);NodeData style = map.get(elemet);//get the type of the assiged valueCSSProperty.Margi mm = style.getProperty("margi-top");System.out.pritl("margi-top=" + mm);//if a legth is specified, obtai the exact valueif (mm == Margi.legth){ TermLegth mtop = style.getValue(TermLegth.class, "margi-top"); System.out.pritl("value=" + mtop);}
评论