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


Java Document.getElementsByAttributeValue方法代码示例

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


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

示例1: allFieldsShouldBePresentInView

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
@Test
public void allFieldsShouldBePresentInView() throws Exception {
    String template = Util.readResource("/role-config.template.html");
    final Document document = Jsoup.parse(template);

    final List<ProfileMetadata> metadataList = MetadataHelper.getMetadata(GitHubRoleConfiguration.class);
    for (ProfileMetadata field : metadataList) {
        final Elements inputFieldForKey = document.getElementsByAttributeValue("ng-model", field.getKey());
        assertThat(inputFieldForKey, hasSize(1));

        final Elements spanToShowError = document.getElementsByAttributeValue("ng-class", "{'is-visible': GOINPUTNAME[" + field.getKey() + "].$error.server}");
        assertThat(spanToShowError, hasSize(1));
        assertThat(spanToShowError.attr("ng-show"), is("GOINPUTNAME[" + field.getKey() + "].$error.server"));
        assertThat(spanToShowError.text(), is("{{GOINPUTNAME[" + field.getKey() + "].$error.server}}"));
    }

    final Elements inputs = document.select("textarea,input,select");
    assertThat("should contains only inputs that defined in GitHubRoleConfiguration.java",inputs, hasSize(metadataList.size()));
}
 
开发者ID:gocd-contrib,项目名称:github-oauth-authorization-plugin,代码行数:20,代码来源:GetRoleConfigViewRequestExecutorTest.java

示例2: allFieldsShouldBePresentInView

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
@Test
public void allFieldsShouldBePresentInView() throws Exception {
    String template = Util.readResource("/profile.template.html");
    final Document document = Jsoup.parse(template);

    for (Metadata field : GetProfileMetadataExecutor.FIELDS) {
        if (field.getKey().equals(GetProfileMetadataExecutor.SPECIFIED_USING_POD_CONFIGURATION.getKey())) {
            continue;
        }
        final Elements inputFieldForKey = document.getElementsByAttributeValue("ng-model", field.getKey());
        assertThat(inputFieldForKey, hasSize(1));

        final Elements spanToShowError = document.getElementsByAttributeValue("ng-class", "{'is-visible': GOINPUTNAME[" + field.getKey() + "].$error.server}");
        assertThat(spanToShowError, hasSize(1));
        assertThat(spanToShowError.attr("ng-show"), is("GOINPUTNAME[" + field.getKey() + "].$error.server"));
        assertThat(spanToShowError.text(), is("{{GOINPUTNAME[" + field.getKey() + "].$error.server}}"));
    }

    final Elements inputs = document.select("textarea,input[type=text],select");
    assertThat(inputs, hasSize(GetProfileMetadataExecutor.FIELDS.size() - 1)); // do not include SPECIFIED_USING_POD_CONFIGURATION key
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:22,代码来源:GetProfileViewExecutorTest.java

示例3: print2

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
private void print2(String baseLocation) throws IOException, TransformerException, ParserConfigurationException {
        Document document = Jsoup.connect(baseLocation).get();
        Elements content = document.getElementsByAttributeValue("class", "entry-content");
        String title = null;
        ArrayList<String> list = new ArrayList<>();
        for (Element div : content) {
            List<Node> nodes = div.childNodes();
            for (Node node : nodes) {
                if (node instanceof Element) {
                    if (((Element) node).tagName().equals("h3")) {
                        writeFile(title, list);
                        list.clear();
                        System.out.println("Title: " + node.childNode(0));
                        title = node.childNode(0).toString();
                    } else if (((Element) node).tagName().equals("table")) {
                        //print table
                        Elements tr = ((Element) node).getElementsByTag("tr");
                        for (Element element : tr) {
                            Elements td = element.getElementsByTag("td");
                            for (Element value : td) {
                                if (value.childNodeSize() > 0) {
                                    if (!(value.childNode(0) instanceof Comment)) {
//                                        System.out.println("Emoticon: " + value.childNode(0) + " " + value.childNode(0).getClass().getSimpleName());
                                        list.add(value.childNode(0).toString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
 
开发者ID:tranleduy2000,项目名称:ascii_generate,代码行数:34,代码来源:GetEmoticons.java

示例4: getContent

import org.jsoup.nodes.Document; //导入方法依赖的package包/类
public String getContent(String contentUrl) {

        try {
            Document document = Jsoup.connect(contentUrl).get();
            Elements details_ele = document.getElementsByAttributeValue("id", "article_details");
            Element article_ele = details_ele.get(0);
            articleContent = article_ele.toString();
            return articleContent;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
 
开发者ID:struggledhard,项目名称:USay,代码行数:14,代码来源:ContentSpliderUtils.java


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