當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。