Java Code Examples for org.jsoup.nodes.Element#appendText()
The following examples show how to use
org.jsoup.nodes.Element#appendText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleTextElementBuilderTest.java From Asqatasun with GNU Affero General Public License v3.0 | 6 votes |
/** * Test of buildTextFromElement method, of class SimpleTextElementBuilder. */ public void testBuildTextFromElementWithChildren() { LOGGER.debug("buildTextFromElementWithChildren"); Element element = new Element(Tag.valueOf("div"), ""); element.appendText(" text1 "); Element childElement = new Element(Tag.valueOf("div"), ""); childElement.text(" child element text "); Element childElement2 = new Element(Tag.valueOf("div"), ""); childElement2.text(" child element text second level "); childElement.appendChild(childElement2); element.appendChild(childElement); element.appendText(" text2 "); SimpleTextElementBuilder instance = new SimpleTextElementBuilder(); String expResult = "text1 child element text child element text second level text2"; String result = instance.buildTextFromElement(element); assertEquals(expResult, result); }
Example 2
Source File: BootstrapHandler.java From flow with Apache License 2.0 | 6 votes |
protected static void setupErrorDialogs(Element style) { // @formatter:off style.appendText( ".v-reconnect-dialog," + ".v-system-error {" + "position: absolute;" + "color: black;" + "background: white;" + "top: 1em;" + "right: 1em;" + "border: 1px solid black;" + "padding: 1em;" + "z-index: 10000;" + "max-width: calc(100vw - 4em);" + "max-height: calc(100vh - 4em);" + "overflow: auto;" + "} .v-system-error {" + "color: indianred;" + "pointer-events: auto;" + "} .v-system-error h3, .v-system-error b {" + "color: red;" + "}"); // @formatter:on }
Example 3
Source File: BootstrapHandler.java From flow with Apache License 2.0 | 5 votes |
private void setupCss(Element head, BootstrapContext context) { Element styles = head.appendElement("style").attr("type", CSS_TYPE_ATTRIBUTE_VALUE); // Add any body style that is defined for the application using // @BodySize String bodySizeContent = BootstrapUtils.getBodySizeContent(context); styles.appendText(bodySizeContent); // Basic reconnect and system error dialog styles just to make them // visible and outside of normal flow setupErrorDialogs(styles); }
Example 4
Source File: Node.java From JsoupXpath with Apache License 2.0 | 5 votes |
/** * 函数具体逻辑 * * @param scope 上下文 * @return 计算好的节点 */ @Override public XValue call(Scope scope) { Elements context = new Elements(); for (Element el:scope.context()){ context.addAll(el.children()); String txt = el.ownText(); if (StringUtils.isNotBlank(txt)){ Element et = new Element(""); et.appendText(txt); context.add(et); } } return XValue.create(context); }
Example 5
Source File: NumTest.java From JsoupXpath with Apache License 2.0 | 5 votes |
/** * Method: call(Elements context) */ @Test public void testCall() throws Exception { Elements context = new Elements(); Element el = new Element("V"); el.appendText("test 33.69"); context.add(el); Num n = new Num(); XValue v = n.call(Scope.create(context)); logger.info("v = {}",v); Assert.assertEquals(33.69,v.asDouble(),0.00000000000001); }
Example 6
Source File: NumTest.java From JsoupXpath with Apache License 2.0 | 5 votes |
@Test public void testShort() throws Exception { Elements context = new Elements(); Element el = new Element("V"); el.appendText("test .69"); context.add(el); Num n = new Num(); XValue v = n.call(Scope.create(context)); logger.info("v = {}",v); Assert.assertEquals(0.69,v.asDouble(),0.00000000000001); }
Example 7
Source File: NumTest.java From JsoupXpath with Apache License 2.0 | 5 votes |
@Test public void testOnZero() throws Exception { Elements context = new Elements(); Element el = new Element("V"); el.appendText("test 69."); context.add(el); Num n = new Num(); XValue v = n.call(Scope.create(context)); logger.info("v = {}",v); Assert.assertEquals(69,v.asDouble(),0.00000000000001); }
Example 8
Source File: StructuralHtml.java From baleen with Apache License 2.0 | 3 votes |
/** * Add text to element * * @param e the element * @param text the text buffer containing the substring * @param start the start offset within the text * @param end the end offset within the text * @return true, if successful */ private boolean appendText(final Element e, final String text, final int start, final int end) { if (start < end && end <= text.length()) { e.appendText(text.substring(start, end)); return true; } else { return false; } }