java中elements类_jsoup的elements类

  • Post author:
  • Post category:java


jsoup的Elements类

一、简介

该类是位于select包下,直接继承自Object,所有实现的接口有Cloneable, Iterable, Collection, List

类声明:public class Elementsextends Object implements List, Cloneable

可以使用Element.select(String) 方法去得到Elements对象。

二、构造方法

1、public Elements()  默认构造方法

2、public Elements(int initialCapacity) 指定一个初始容量创建一个Elements对象。

3、public Elements(Collection elements)  使用已知元素集创建一个Elements对象。

4、public Elements(List elements)  使用已知元素的List集合创建一个Elements对象。

5、public Elements(Element… elements) 使用已知元素的可变参数列表创建一个Elements对象。

三、方法详细

1、public Elements clone()  克隆

2、public String attr(String attributeKey) 根据键得到第一个匹配的元素(匹配即为有这个属性)。

3、public boolean hasAttr(String attributeKey)   元素集中存在任何一个元素匹配(有这属性)则返回true。

4、public Elements attr(String attributeKey, String attributeValue) 将 所有匹配attributeKey键的元素的值设置为attributeValue。

5、public Ele



版权声明:本文为weixin_36268255原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。