Example usage for org.jsoup.nodes DataNode getWholeData

List of usage examples for org.jsoup.nodes DataNode getWholeData

Introduction

In this page you can find the example usage for org.jsoup.nodes DataNode getWholeData.

Prototype

public String getWholeData() 

Source Link

Document

Get the data contents of this node.

Usage

From source file:fr.isen.browser5.Util.UrlLoader.java

public void getScripts() {
    Elements scriptElements = doc.getElementsByTag("script");
    for (Element element : scriptElements) {
        for (DataNode node : element.dataNodes()) {
            script += node.getWholeData();
        }//  w  w w.j a va 2s  . c  o m
    }
}

From source file:psef.handler.HTMLFilter.java

/**
 * Revise all "style" statements with @import directives
 * @param doc the DOM document/*  w w w. j  a  v  a  2 s .c om*/
 * @throws PsefException 
 */
private void filterStyles(Document doc) throws PsefException {
    try {
        Elements styles = doc.getElementsByTag("style");
        for (Element style : styles) {
            List<DataNode> data = style.dataNodes();
            String styleText = "";
            StringBuilder sb = new StringBuilder();
            for (DataNode node : data) {
                styleText = node.getWholeData();
                int pos = readAtImport(styleText);
                while (pos > 0) {
                    sb.append("@import ");
                    styleText = styleText.substring(pos);
                    CSSUrl cssu = new CSSUrl(styleText);
                    styleText = styleText.substring(cssu.getPos());
                    cssu.revise(host, base + relPath, "styles");
                    URL u = new URL(cssu.getUrl(host, base + relPath));
                    downloadResource(u, cssu.getLocalPath());
                    sb.append(cssu.toString());
                    sb.append("\n");
                    pos = readAtImport(styleText);
                }
                node.setWholeData(sb.toString());
            }
            sb.append(styleText);
            //style.( sb.toString() );
        }
    } catch (Exception e) {
        throw new PsefException(e);
    }
}