Java HTML Jsoup Element isChildOf(Element child, Elements possibleParents)

Here you can find the source of isChildOf(Element child, Elements possibleParents)

Description

Determines whether the given element is a child of one of the given parent elements.

License

Open Source License

Parameter

Parameter Description
child the child element
possibleParents the possible parents

Return

true if it is a child, false if not

Declaration

public static boolean isChildOf(Element child, Elements possibleParents) 

Method Source Code

//package com.java2s;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class Main {
    /**/*from w w  w. java  2 s  .c o m*/
     * Determines whether the given element is a child of one of the given
     * parent elements.
     * @param child the child element
     * @param possibleParents the possible parents
     * @return true if it is a child, false if not
     */
    public static boolean isChildOf(Element child, Elements possibleParents) {
        for (Element parent : child.parents()) {
            if (possibleParents.contains(parent)) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. getTextFromMultipleSelect(Element doc, String location, String locationValue)
  2. getTextFromNodeIfAvailable(Element doc)
  3. getTextFromNodeSelect(Element doc, String location, String locationValue)
  4. getTitle(Element el, String[] titles)
  5. getUserId(Element authorElement)
  6. isEmptyElement(Node node)
  7. markAll(Elements tags)
  8. markChildren(Element tag, final String color)
  9. printNode(Element root)