13.Setting the text content of elements
来源:百度文库 编辑:神马文学网 时间:2024/04/28 11:37:25
Setting the text content of elements
Problem
You need to modify the text content of a HTML document.
Solution
Use the text setter methods of Element
:
Element div = doc.select("div").first(); //
div.text("five > four"); // five > four
div.prepend("First ");div.append(" Last");
// now: First five > four Last
Discussion
The text setter methods mirror the HTML setter methods:
Element.text(String text)
clears any existing inner HTML in an element, and replaces it with the supplied text.Element.prepend(String first)
andElement.append(String last)
add text nodes to the start or end of an element's inner HTML, respectively
The text should be supplied unencoded: characters like <
, >
etc will be treated as literals, not HTML.
13.Setting the text content of elements
[Writing] The Elements of Style
The Elements of Programming Style
The Psychology of Text Relationships
The Elements of Cache Programming Style
Content Strategy: The Philosophy of Data
Full text of Communique of the Fifth Plenum of the 17th CPC Central Committee
eResumeIQ.com -- The ABCs of ASCII (plain text) Resumes
Elements of success
Elements of GUI Testing
8. Extract attributes, text, and HTML from elements
Text of Steve Jobs‘ Commencement address (2005)
Text of Steve Jobs' Commencement address (2005)
Text of Steve Jobs' Commencement address (2005)
Blogs as Disruptive Tech - How weblogs are flying under the radar of the Content Management Giants - Our Stories - Articles about our company, WebCrimson
Full text of Barack Obama's acceptance of th...
【The Setting Sun】-人像摄影论坛-ZOL中关村在线
A Nation of Web Content Creators
The power of the podcast
The color of the night
The Colors of the Rainbow
The Awesomeness of the Thundercats
The History of the Cars
The Rule of Distraction