Codota Logo
org.jsoup.nodes
Code IndexAdd Codota to your IDE (free)

How to use org.jsoup.nodes

Best Java code snippets using org.jsoup.nodes (Showing top 20 results out of 4,104)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Gson g =
  • Codota Iconnew Gson()
  • Codota IconGsonBuilder gsonBuilder;gsonBuilder.create()
  • Codota Iconnew GsonBuilder().create()
  • Smart code suggestions by Codota
}
origin: code4craft/webmagic

@Override
public List<Element> selectElements(Element element) {
  return element.select(selectorText);
}
origin: k9mail/k-9

  public static String toCompactString(Document document) {
    document.outputSettings()
        .prettyPrint(false)
        .indentAmount(0);

    return document.html();
  }
}
origin: org.jsoup/jsoup

@Override
public Node removeAttr(String key) {
  ensureAttributes();
  return super.removeAttr(key);
}
origin: square/retrofit

 @Override public Page convert(ResponseBody responseBody) throws IOException {
  Document document = Jsoup.parse(responseBody.string());
  List<String> links = new ArrayList<>();
  for (Element element : document.select("a[href]")) {
   links.add(element.attr("href"));
  }
  return new Page(document.title(), Collections.unmodifiableList(links));
 }
}
origin: org.jsoup/jsoup

/**
 Set the text of the {@code body} of this document. Any existing nodes within the body will be cleared.
 @param text unencoded text
 @return this document
 */
@Override
public Element text(String text) {
  body().text(text); // overridden to not nuke doc structure
  return this;
}
origin: code4craft/webmagic

protected String getText(Element element) {
  StringBuilder accum = new StringBuilder();
  for (Node node : element.childNodes()) {
    if (node instanceof TextNode) {
      TextNode textNode = (TextNode) node;
      accum.append(textNode.text());
    }
  }
  return accum.toString();
}
origin: code4craft/webmagic

/**
 * Only document can be select
 * See: https://github.com/code4craft/webmagic/issues/113
 *
 * @param elementIterator elementIterator
 * @return element element
 */
private Element checkElementAndConvert(ListIterator<Element> elementIterator) {
  Element element = elementIterator.next();
  if (!(element instanceof Document)) {
    Document root = new Document(element.ownerDocument().baseUri());
    Element clone = element.clone();
    root.appendChild(clone);
    elementIterator.set(root);
    return root;
  }
  return element;
}
origin: org.jsoup/jsoup

/**
 * Get the {@code id} attribute of this element.
 * 
 * @return The id attribute, if present, or an empty string if not.
 */
public String id() {
  return attributes().getIgnoreCase("id");
}
origin: org.jsoup/jsoup

  public void tail(Node node, int depth) {
    // make sure there is a space between block tags and immediately following text nodes <div>One</div>Two should be "One Two".
    if (node instanceof Element) {
      Element element = (Element) node;
      if (element.isBlock() && (node.nextSibling() instanceof TextNode) && !TextNode.lastCharIsWhitespace(accum))
        accum.append(' ');
    }
  }
}, this);
origin: org.jsoup/jsoup

/**
 * Create a new TextNode from HTML encoded (aka escaped) data.
 * @param encodedText Text containing encoded HTML (e.g. &amp;lt;)
 * @return TextNode containing unencoded data (e.g. &lt;)
 */
public static TextNode createFromEncoded(String encodedText) {
  String text = Entities.unescape(encodedText);
  return new TextNode(text);
}
origin: org.jsoup/jsoup

  /**
   Create a new DataNode from HTML encoded data.
   @param encodedData encoded data
   @param baseUri bass URI
   @return new DataNode
   */
  public static DataNode createFromEncoded(String encodedData, String baseUri) {
    String data = Entities.unescape(encodedData);
    return new DataNode(data);
  }
}
origin: org.jsoup/jsoup

/**
 * Set an attribute (key=value). If the attribute already exists, it is replaced. The attribute key comparison is
 * <b>case insensitive</b>.
 * @param attributeKey The attribute key.
 * @param attributeValue The attribute value.
 * @return this (for chaining)
 */
public Node attr(String attributeKey, String attributeValue) {
  attributes().putIgnoreCase(attributeKey, attributeValue);
  return this;
}
origin: org.jsoup/jsoup

private void ensureAttributes() {
  if (!hasAttributes()) {
    Object coreValue = value;
    Attributes attributes = new Attributes();
    value = attributes;
    if (coreValue != null)
      attributes.put(nodeName(), (String) coreValue);
  }
}
origin: org.jsoup/jsoup

@Override
public Document clone() {
  Document clone = (Document) super.clone();
  clone.outputSettings = this.outputSettings.clone();
  return clone;
}

origin: org.jsoup/jsoup

@Override
public boolean hasAttr(String key) {
  ensureAttributes();
  return super.hasAttr(key);
}
origin: org.jsoup/jsoup

@Override
public Attributes attributes() {
  if (!hasAttributes())
    attributes = new Attributes();
  return attributes;
}
origin: org.jsoup/jsoup

@Override
public String baseUri() {
  return hasParent() ? parent().baseUri() : "";
}
origin: org.jsoup/jsoup

/**
 * Create a new Attribute from an unencoded key and a HTML attribute encoded value.
 * @param unencodedKey assumes the key is not encoded, as can be only run of simple \w chars.
 * @param encodedValue HTML attribute encoded value
 * @return attribute
 */
public static Attribute createFromEncoded(String unencodedKey, String encodedValue) {
  String value = Entities.unescape(encodedValue, true);
  return new Attribute(unencodedKey, value, null); // parent will get set when Put
}
origin: org.jsoup/jsoup

@Override
public String absUrl(String key) {
  ensureAttributes();
  return super.absUrl(key);
}
origin: org.jsoup/jsoup

/**
 * Create a new TextNode from HTML encoded (aka escaped) data.
 * @param encodedText Text containing encoded HTML (e.g. &amp;lt;)
 * @param baseUri Base uri
 * @return TextNode containing unencoded data (e.g. &lt;)
 * @deprecated use {@link TextNode#createFromEncoded(String)} instead, as LeafNodes don't carry base URIs.
 */
public static TextNode createFromEncoded(String encodedText, String baseUri) {
  String text = Entities.unescape(encodedText);
  return new TextNode(text);
}
org.jsoup.nodes

Most used classes

  • Document
  • Element
  • TextNode
  • Node
  • Document$OutputSettings
  • Attribute,
  • DataNode,
  • Comment,
  • DocumentType,
  • XmlDeclaration,
  • FormElement,
  • Attributes$Dataset$DatasetIterator,
  • Attributes$Dataset$EntrySet,
  • Attributes$Dataset,
  • BooleanAttribute,
  • CDataNode,
  • Element$NodeList,
  • Entities$CoreCharset,
  • Entities$EscapeMode
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now