/** * {@inheritDoc} */ @Override public <T extends Appendable> T html(T appendable) { for (Node node : childNodes) node.outerHtml(appendable); return appendable; }
/** * Write this node and its children to the given {@link Appendable}. * * @param appendable the {@link Appendable} to write to. * @return the supplied {@link Appendable}, for chaining. */ public <T extends Appendable> T html(T appendable) { outerHtml(appendable); return appendable; }
private void html(StringBuilder accum) { for (Node node : childNodes) node.outerHtml(accum); }
public String toString() { return outerHtml(); }
/** * Check if this node is has the same content as another node. A node is considered the same if its name, attributes and content match the * other node; particularly its position in the tree does not influence its similarity. * @param o other object to compare to * @return true if the content of this node is the same as the other */ public boolean hasSameValue(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; return this.outerHtml().equals(((Node) o).outerHtml()); }
/** Get the outer HTML of this node. @return HTML */ public String outerHtml() { StringBuilder accum = new StringBuilder(128); outerHtml(accum); return accum.toString(); }
sb.append('\n'); sb.append(node.outerHtml());
public static String readAnnotation(Node node) { if (null == node) return null; Node preceding = node.previousSibling(); //if this is a text node, then match for annotations return readAnnotation(node.outerHtml()); }
public static String readAnnotation(Node node) { if (null == node) return null; Node preceding = node.previousSibling(); //if this is a text node, then match for annotations return readAnnotation(node.outerHtml()); }
public static String readAnnotation(Node node) { if (null == node) return null; Node preceding = node.previousSibling(); //if this is a text node, then match for annotations return readAnnotation(node.outerHtml()); }
/** * Gets the outer HTML for the element. * <p> * This operation recursively iterates the element and all children and * should not be called unnecessarily. * * @return the outer HTML for the element */ public String getOuterHTML() { return ElementUtil.toJsoup(new Document(""), this).outerHtml(); }
public void getHtmlStartingFromText(String text, StringBuilder builder, List<Node> nodesList, boolean append) { for (Node node : nodesList) { String nodeName = node.nodeName(); if (append) { builder.append(node.outerHtml()); continue; } if (nodeName.equalsIgnoreCase("#text")) { if (node.toString().trim().equalsIgnoreCase(text)) append = true; } getHtmlStartingFromText(text, builder, node.childNodes(), append); } }
public void getHtmlStartingFromText(String text, StringBuilder builder, List<Node> nodesList, boolean append) { for (Node node : nodesList) { String nodeName = node.nodeName(); if (append) { builder.append(node.outerHtml()); continue; } if (nodeName.equalsIgnoreCase("#text")) { if (node.toString().trim().equalsIgnoreCase(text)) append = true; } getHtmlStartingFromText(text, builder, node.childNodes(), append); } }
private void getHtmlStartingFromNode(String nodeType, String attrib, String attribValue, StringBuilder builder, List<Node> nodesList, boolean append) { for (Node node : nodesList) { String nodeName = node.nodeName(); if (append) { if (node.nodeName().equalsIgnoreCase("#text") && node.outerHtml().charAt(0) != ' ') builder.append(" "); builder.append(node.outerHtml()); if (!node.nodeName().equalsIgnoreCase("#text")) builder.append(" "); continue; } if (nodeName.equalsIgnoreCase(nodeType)) { if (node.attributes().hasKey(attrib) && node.attr(attrib).equalsIgnoreCase(attribValue)) append = true; } getHtmlStartingFromNode(nodeType, attrib, attribValue, builder, node.childNodes(), append); } }
private void getHtmlStartingFromNode(String nodeType, String attrib, String attribValue, StringBuilder builder, List<Node> nodesList, boolean append) { for (Node node : nodesList) { String nodeName = node.nodeName(); if (append) { if (node.nodeName().equalsIgnoreCase("#text") && node.outerHtml().charAt(0) != ' ') builder.append(" "); builder.append(node.outerHtml()); if (!node.nodeName().equalsIgnoreCase("#text")) builder.append(" "); continue; } if (nodeName.equalsIgnoreCase(nodeType)) { if (node.attributes().hasKey(attrib) && node.attr(attrib).equalsIgnoreCase(attribValue)) append = true; } getHtmlStartingFromNode(nodeType, attrib, attribValue, builder, node.childNodes(), append); } }
public static String getText(Element cell) { StringBuilder textBuilder = new StringBuilder(); for (Node node : cell.childNodes()) { if (node instanceof TextNode) { textBuilder.append(((TextNode)node).getWholeText()); } else { for (Node childNode : node.childNodes()) { textBuilder.append(getText((Element)childNode)); } textBuilder.append(node.outerHtml()); } } if (cell.childNodes().isEmpty()) { textBuilder.append(cell.outerHtml()); } return textBuilder.toString(); }
private static void moveNodes(Elements sourceNodes, Element targetElement) { for (Element element : sourceNodes) { element.remove(); for (Node node : element.childNodes()) targetElement.append(node.outerHtml()); } }
private void checkUriConsistency(PageCompilingContext pc, Node element) { String uriAttrib = element.attr("action"); if (null == uriAttrib) uriAttrib = element.attr("src"); if (null == uriAttrib) uriAttrib = element.attr("href"); if (null != uriAttrib) { // Verify that such a uri exists in the page book, // only if it is contextual--ignore abs & relative URIs. if (uriAttrib.startsWith("/")) if (null == pageBook.nonCompilingGet(uriAttrib)) pc.warnings.add( CompileError.in(element.outerHtml()) .near(element.siblingIndex()) // TODO - line number .causedBy(CompileErrors.UNRESOLVABLE_FORM_ACTION, uriAttrib) ); } }
private void checkUriConsistency(PageCompilingContext pc, Node element) { String uriAttrib = element.attr("action"); if (null == uriAttrib) uriAttrib = element.attr("src"); if (null == uriAttrib) uriAttrib = element.attr("href"); if (null != uriAttrib) { // Verify that such a uri exists in the page book, // only if it is contextual--ignore abs & relative URIs. if (uriAttrib.startsWith("/")) if (null == pageBook.nonCompilingGet(uriAttrib)) pc.warnings.add( CompileError.in(element.outerHtml()) .near(element.siblingIndex()) // TODO - line number .causedBy(CompileErrors.UNRESOLVABLE_FORM_ACTION, uriAttrib) ); } }
private void checkUriConsistency(Node element) { String uriAttrib = element.attr("action"); if (null == uriAttrib) uriAttrib = element.attr("src"); if (null == uriAttrib) uriAttrib = element.attr("href"); if (null != uriAttrib) { // Verify that such a uri exists in the page book, // only if it is contextual--ignore abs & relative URIs. final String uri = uriAttrib; if (uri.startsWith("/")) if (null == pageBook.nonCompilingGet(uri)) warnings.add( CompileError.in(element.outerHtml()) .near(element.siblingIndex()) // TODO - line number .causedBy(CompileErrors.UNRESOLVABLE_FORM_ACTION, uri) ); } }