本文整理匯總了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
}
示例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());
}
}
}
}
}
}
}
}
}
示例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;
}