problem
After you resolve a Document may want to modify some of the properties of these values, and then saved to disk or are output to the front page.
method
Attribute setting method can be used Element.attr(String key, String value)
, and Elements.attr(String key, String value)
.
If you need to modify an element class
property can be used Element.addClass(String className)
and Element.removeClass(String className)
methods.
Elements
Bulk operating element is provided a method and class attributes, such as: To each of a div element can add a rel="nofollow"
method can be used:
doc.select("div.comments a").attr("rel", "nofollow");
Explanation
And Element
as the other methods, attr
the method also returns when Element
(or return selector using Elements
a collection). This can easily use the notation method used in conjunction. such as:
doc.select("div.masthead").attr("title", "jsoup").addClass("round-box");