当前位置: 首页>>代码示例>>Java>>正文


Java Element.getAttributeValue方法代码示例

本文整理汇总了Java中net.htmlparser.jericho.Element.getAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getAttributeValue方法的具体用法?Java Element.getAttributeValue怎么用?Java Element.getAttributeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.htmlparser.jericho.Element的用法示例。


在下文中一共展示了Element.getAttributeValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matches

import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
public boolean matches(Element e, ClassSelector simpleSelector) {
    String attrClass = e.getAttributeValue("class");
    return attrClass != null && Pattern.compile(
            ".*(\\s|^)" + Pattern.quote(simpleSelector.getClassName()) + "(\\s|$).*", Pattern.DOTALL)
            .matcher(attrClass)
            .matches();
}
 
开发者ID:utluiz,项目名称:jericho-selector,代码行数:8,代码来源:ClassSelectorMatcher.java

示例2: isUserInterfaceElementChecked

import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
/**
 * http://www.w3.org/TR/html5/disabled-elements.html
 */
protected boolean isUserInterfaceElementChecked(Element e) {
    String type = e.getAttributeValue("type");
    if ("input".equals(e.getName())) {
        return e.getAttributes().get("checked") != null 
                && ("checkbox".equals(type) || "radio".equals(type)); 
    }
    return "option".equals(e.getName()) && e.getAttributes().get("selected") != null;
}
 
开发者ID:utluiz,项目名称:jericho-selector,代码行数:12,代码来源:PseudoSelectorMatcher.java

示例3: main

import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
        
        if (args.length > 0)
            inDir = args[0];
        if (args.length > 1)
            outDir = args[1];
        else
            outDir = inDir;
        
        File f = new File(inDir);
        
        for (File doc : f.listFiles()){
        
        String sourceUrlString="file:"+inDir+doc.getName();
        
        MicrosoftConditionalCommentTagTypes.register();
        PHPTagTypes.register();
        PHPTagTypes.PHP_SHORT.deregister(); // remove PHP short tags for this example otherwise they override processing instructions
        MasonTagTypes.register();
        Source source=new Source(new URL(sourceUrlString));

        PrintStream ps = new PrintStream(outDir+doc.getName().replaceFirst(".html", "")+".txt");
        
        PrintStream ps_key = new PrintStream(outDir+doc.getName().replaceFirst(".html", "")+".key");
        
        // Call fullSequentialParse manually as most of the source will be parsed.
        source.fullSequentialParse();

//		System.out.println("Document title:");
        String title=getTitle(source);
        ps.print(title+"\n\n");
//		System.out.println("\nDocument description:");
        String description=getMetaValue(source,"description");
        ps.println(description+"\n\n");
//		System.out.println("\nDocument keywords:");
        String keywords=getMetaValue(source,"keywords");
        if (keywords != null)
            ps_key.print(keywords.replaceAll("\\s*,\\s*", "\n"));
        ps_key.close();
        
        List<Element> divElements=source.getAllElements(HTMLElementName.DIV);
        for (Element div : divElements) {
            String id=div.getAttributeValue("id");
            if (id==null) 
                continue;
            else if (id.equals("article-body-blocks")){
                String article=div.getContent().getTextExtractor().toString();
                ps.println(article);
            }
        }
        ps.close();
        }

  }
 
开发者ID:EUMSSI,项目名称:EUMSSI-tools,代码行数:55,代码来源:ExtractGuardian.java

示例4: matches

import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
public boolean matches(Element e, AttributeSelector simpleSelector) {
    String attrName = simpleSelector.getName();
    if (simpleSelector.getOperator() == null) {
        return e.getAttributes().get(attrName) != null;
    } else if (e.getAttributes().get(attrName) != null) {
        String expectedValue = simpleSelector.getValue() == null ? null : simpleSelector.getValue().getActualValue();
        String currentValue = e.getAttributeValue(attrName);
        
        if (currentValue == null || currentValue.isEmpty()) {
            return AttributeOperator.EQUALS.equals(simpleSelector.getOperator()) 
                    && (expectedValue == null || expectedValue.isEmpty()); 
        }
        
        if ((expectedValue == null || expectedValue.isEmpty())
                && !AttributeOperator.EQUALS.equals(simpleSelector.getOperator()) ) {
            return false;
        }
        
        switch (simpleSelector.getOperator()) {
        case EQUALS:
            return currentValue.equals(expectedValue);
        case INCLUDES:
            String[] words = currentValue.split("[\\s]+");
            for (String word : words) {
                if (word.equals(expectedValue)) {
                    return true;
                }
            }
            return false;
        case DASH_MATCH:
            return currentValue.equals(expectedValue) || currentValue.startsWith(expectedValue + "-");
        case PREFIX_MATCH:
            return currentValue.startsWith(expectedValue);
        case SUBSTRING_MATCH:
            return currentValue.contains(expectedValue);
        case SUFFIX_MATCH:
            return currentValue.endsWith(expectedValue);
        }
    }
    return false;
}
 
开发者ID:utluiz,项目名称:jericho-selector,代码行数:42,代码来源:AttributeSelectorMatcher.java

示例5: matches

import net.htmlparser.jericho.Element; //导入方法依赖的package包/类
public boolean matches(Element e, HashSelector simpleSelector) {
    String id = e.getAttributeValue("id");
    return id != null && e.getAttributeValue("id").equals(simpleSelector.getName());
}
 
开发者ID:utluiz,项目名称:jericho-selector,代码行数:5,代码来源:HashSelectorMatcher.java


注:本文中的net.htmlparser.jericho.Element.getAttributeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。