/** * Gets the combined HTML contents of each element in the set of * matched elements, including their descendants. * @see #html() * @param setIncluded if <code>true</code> than sets node are included in the output */ public String htmlAll(final boolean setIncluded) { if (nodes.length == 0) { return StringPool.EMPTY; } StringBuilder sb = new StringBuilder(); for (Node node : nodes) { sb.append(setIncluded ? node.getHtml() : node.getInnerHtml()); } return sb.toString(); }
private String actualHtml(Jerry $) { return $.root().get(0).getHtml(); }
@Test void testAbstractFormController() throws IOException { File file = new File(testDataRoot, "AbstractFormController.html"); String content = FileUtil.readString(file); Jerry.JerryParser jerryParser = new Jerry.JerryParser(); //jerryParser.getDOMBuilder().setCalculatePosition(true); Jerry doc = jerryParser.parse(content); // parse doc.$("a").each(($this, index) -> { assertEquals("<a name=\"navbar_top\"><!-- --></a>", $this.get()[0].getHtml()); return false; }); }
@Test void testPortletUtils() throws IOException { File file = new File(testDataRoot, "PortletUtils.html"); String content = FileUtil.readString(file); Jerry.JerryParser jerryParser = new Jerry.JerryParser(); //jerryParser.getDOMBuilder().setCalculatePosition(true); Jerry doc = jerryParser.parse(content); // parse doc.$("a").each(($this, index) -> { assertEquals("<a name=\"navbar_top\"><!-- --></a>", $this.get()[0].getHtml()); return false; }); }
/** * Gets the combined HTML contents of each element in the set of * matched elements, including their descendants. * * @param setIncluded if <code>true</code> than sets node are included in the output * @see #html() */ public String htmlAll(boolean setIncluded) { StringBuilder sb = new StringBuilder(); for (Node node : nodes) { sb.append(setIncluded ? node.getHtml() : node.getInnerHtml()); } return sb.toString(); }
/** * Gets the combined HTML contents of each element in the set of * matched elements, including their descendants. * @see #html() * @param setIncluded if <code>true</code> than sets node are included in the output */ public String htmlAll(final boolean setIncluded) { if (nodes.length == 0) { return StringPool.EMPTY; } StringBuilder sb = new StringBuilder(); for (Node node : nodes) { sb.append(setIncluded ? node.getHtml() : node.getInnerHtml()); } return sb.toString(); }
@Override public List<String> extractList(String data) { List<String> strings = new LinkedList<>(); Jerry doc = jerry(data); Node[] nodes = doc.$(query).get(); for (Node node : nodes) { switch (outType) { case TYPE_TEXT: strings.add(parse(node.getTextContent())); break; case TYPE_HTML: strings.add(parse(node.getHtml())); break; default: strings.add(parse(node.getAttribute(outType))); break; } } return strings; }