Java HTML Jsoup Element updateData(Element element, String data)

Here you can find the source of updateData(Element element, String data)

Description

Update given element's data to new data.

License

Apache License

Declaration

public static Element updateData(Element element, String data) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import org.jsoup.nodes.DataNode;
import org.jsoup.nodes.Element;
import java.util.List;

public class Main {
    /**/*from ww w.ja v  a  2s .c o  m*/
     * Update given element's data to new data.
     */
    public static Element updateData(Element element, String data) {
        List<DataNode> dataNodes = element.dataNodes();
        for (DataNode dataNode : dataNodes) {
            dataNode.setWholeData("");
        }
        dataNodes.get(0).setWholeData(data);
        return element;
    }
}

Related

  1. sameTagElNums(Element e)
  2. setAttribute(Element e, String key, String value)
  3. stripAttribute(Element body, String attribute)
  4. stripEmptyDivs(Element body)
  5. stripStyles(Element body)