Example usage for org.jsoup.nodes Document empty

List of usage examples for org.jsoup.nodes Document empty

Introduction

In this page you can find the example usage for org.jsoup.nodes Document empty.

Prototype

public Element empty() 

Source Link

Document

Remove all of the element's child nodes.

Usage

From source file:com.dajodi.scandic.JSoupScraper.java

@Override
public Map<String, String> scrapeFormInputFields(InputStream inStream) {

    try {/*from   ww w .j av a2s  .c  o  m*/
        Document doc = Jsoup.parse(inStream, HTTP.UTF_8, "");

        Element form = doc.body().getElementById("aspnetForm");

        Elements inputNodes = form.getElementsByTag("input");
        Map<String, String> inputMap = new HashMap<String, String>();

        for (Element element : inputNodes) {

            String name = element.attr("name");
            String value = element.attr("value");

            if (name != null) {
                inputMap.put(name, value == null ? "" : value);
            } else {
                //TODO: remove me
                Log.d("Something weird");
            }
        }

        doc.empty();
        return inputMap;
    } catch (Exception e) {
        throw new ScandicHtmlException(e);
    }
}