/** * Returns the text content of a descendant of {@code root}. * * @param root * The element from which to begin the search. * * @param path * The path to the descendant, relative to {@code root}. * * @return * The text of the descedant, or {@code null} if no such descendant * exists. * * @see #getElement(Element, String) * @see Element#getText() */ public static String getText(Element root, String path) { Element element = getElement(root, path); return (element == null) ? null : element.getText(); }
/** * Returns the text content of a descendant of {@code root}. * * @param root * The element from which to begin the search. * * @param path * The path to the descendant, relative to {@code root}. * * @return * The text of the descedant, or {@code null} if no such descendant * exists. * * @see #getElement(Element, String) * @see Element#getText() */ public static String getText(Element root, String path) { Element element = getElement(root, path); return (element == null) ? null : element.getText(); }
/** * Returns the sub-elements of a descendant of {@code root} whose tag names * match the given name. * * @param root * The element from which to begin the search. * * @param path * The path to the descendant, relative to {@code root}. * * @param name * The tag name to match. * * @return * The matching elements, or {@code null} if no such descendant exists. * * @see #getElement(Element, String) * @see Element#getElements(String) */ public static List<Element> getElements(Element root, String path, String name) { Element element = getElement(root, path); return (element == null) ? null : element.getElements(name); }
/** * Returns the sub-elements of a descendant of {@code root} whose tag names * match the given name. * * @param root * The element from which to begin the search. * * @param path * The path to the descendant, relative to {@code root}. * * @param name * The tag name to match. * * @return * The matching elements, or {@code null} if no such descendant exists. * * @see #getElement(Element, String) * @see Element#getElements(String) */ public static List<Element> getElements(Element root, String path, String name) { Element element = getElement(root, path); return (element == null) ? null : element.getElements(name); }