Java Code Examples for org.jsoup.nodes.Node#nodeName()
The following examples show how to use
org.jsoup.nodes.Node#nodeName() .
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: HtmlToPlainText.java From lemminx with Eclipse Public License 2.0 | 6 votes |
@Override public void head(Node node, int depth) { String name = node.nodeName(); if (node instanceof TextNode) { append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM. } else if (name.equals("ul")) { listNesting++; } else if (name.equals("li")) { append("\n "); for (int i = 1; i < listNesting; i++) { append(" "); } if (listNesting == 1) { append("* "); } else { append("- "); } } else if (name.equals("dt")) { append(" "); } else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr")) { append("\n"); } }
Example 2
Source File: Paragraph.java From dkpro-c4corpus with Apache License 2.0 | 6 votes |
public String getPath(Node n) { String nodePath = ""; while (n != null) { if (n instanceof TextNode) { n = n.parent(); } if (NodeHelper.isInnerText(n)) { n = n.parent(); } String parentNodeName = n.nodeName(); nodePath = parentNodeName + "." + nodePath; if (!parentNodeName.equalsIgnoreCase("html")) { n = n.parent(); } else { break; } } return nodePath; }
Example 3
Source File: HtmlToPlainText.java From astor with GNU General Public License v2.0 | 5 votes |
public void head(Node node, int depth) { String name = node.nodeName(); if (node instanceof TextNode) append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM. else if (name.equals("li")) append("\n * "); else if (name.equals("dt")) append(" "); else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr")) append("\n"); }
Example 4
Source File: HtmlToPlainText.java From astor with GNU General Public License v2.0 | 5 votes |
public void tail(Node node, int depth) { String name = node.nodeName(); if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5")) append("\n"); else if (name.equals("a")) append(String.format(" <%s>", node.absUrl("href"))); }
Example 5
Source File: HtmlToPlainText.java From astor with GNU General Public License v2.0 | 5 votes |
public void head(Node node, int depth) { String name = node.nodeName(); if (node instanceof TextNode) append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM. else if (name.equals("li")) append("\n * "); else if (name.equals("dt")) append(" "); else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr")) append("\n"); }
Example 6
Source File: HtmlToPlainText.java From echo with Apache License 2.0 | 5 votes |
public void tail(Node node, int depth) { String name = node.nodeName(); if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5")) { append("\n"); } else if (name.equals("a")) { append(String.format(" <%s>", node.absUrl("href"))); } }
Example 7
Source File: HtmlToPlainText.java From echo with Apache License 2.0 | 5 votes |
public void head(Node node, int depth) { String name = node.nodeName(); if (node instanceof TextNode) { append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM. } else if (name.equals("li")) { append("\n * "); } else if (name.equals("dt")) { append(" "); } else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr")) { append("\n"); } }
Example 8
Source File: HtmlToPlainText.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public void tail(Node node, int depth) { String name = node.nodeName(); if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5")) { append("\n"); } else if (StringUtil.in(name, "th", "td")) { append(" "); } else if (name.equals("a")) { append(String.format(" <%s>", node.absUrl("href"))); } else if (name.equals("ul")) { listNesting--; } }
Example 9
Source File: HtmlToPlainText.java From astor with GNU General Public License v2.0 | 5 votes |
public void tail(Node node, int depth) { String name = node.nodeName(); if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5")) append("\n"); else if (name.equals("a")) append(String.format(" <%s>", node.absUrl("href"))); }
Example 10
Source File: HtmlToPlainText.java From astor with GNU General Public License v2.0 | 5 votes |
public void head(Node node, int depth) { String name = node.nodeName(); if (node instanceof TextNode) append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM. else if (name.equals("li")) append("\n * "); else if (name.equals("dt")) append(" "); else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr")) append("\n"); }
Example 11
Source File: FormattingVisitor.java From Recaf with MIT License | 5 votes |
@Override public void head(Node node, int depth) { String name = node.nodeName(); // TextNodes carry all user-readable text in the DOM. if(node instanceof TextNode) text(((TextNode) node).text()); // Other nodes are used only for formatting, not content else if(name.equals("li")) text("\n * "); else if(name.equals("dt")) text(" "); else if(StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr")) spacing(node); }
Example 12
Source File: HtmlToPlainText.java From jsoup-learning with MIT License | 5 votes |
public void head(Node node, int depth) { String name = node.nodeName(); if (node instanceof TextNode) append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM. else if (name.equals("li")) append("\n * "); }
Example 13
Source File: HtmlToPlainText.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public void tail(Node node, int depth) { String name = node.nodeName(); if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5")) { append("\n"); } else if (StringUtil.in(name, "th", "td")) { append(" "); } else if (name.equals("a")) { append(String.format(" <%s>", node.absUrl("href"))); } else if (name.equals("ul")) { listNesting--; } }
Example 14
Source File: HtmlToPlainText.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
public void tail(Node node, int depth) { String name = node.nodeName(); if (StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5")) append("\n"); else if (name.equals("a")) append(String.format(" <%s>", node.absUrl("href"))); }
Example 15
Source File: HtmlToPlainText.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
public void head(Node node, int depth) { String name = node.nodeName(); if (node instanceof TextNode) append(((TextNode) node).text()); // TextNodes carry all user-readable text in the DOM. else if (name.equals("li")) append("\n * "); else if (name.equals("dt")) append(" "); else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5", "tr")) append("\n"); }
Example 16
Source File: HtmlToPlainText.java From jsoup-learning with MIT License | 5 votes |
public void tail(Node node, int depth) { String name = node.nodeName(); if (name.equals("br")) append("\n"); else if (StringUtil.in(name, "p", "h1", "h2", "h3", "h4", "h5")) append("\n\n"); else if (name.equals("a")) append(String.format(" <%s>", node.absUrl("href"))); }
Example 17
Source File: MlMessageParser.java From symphony-java-client with Apache License 2.0 | 4 votes |
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); } }
Example 18
Source File: FormattingVisitor.java From Recaf with MIT License | 4 votes |
@Override public void tail(Node node, int depth) { String name = node.nodeName(); if(StringUtil.in(name, "br", "dd", "dt", "p", "h1", "h2", "h3", "h4", "h5", "ul", "ol", "table")) spacing(node); }
Example 19
Source File: MlMessageParser.java From symphony-java-client with Apache License 2.0 | 3 votes |
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); } }
Example 20
Source File: MlMessageParser.java From symphony-java-client with Apache License 2.0 | 3 votes |
private void updateMentionUidToEmail(SymphonyClient symClient, List<Node> nodesList) { for (Node node : nodesList) { String nodeName = node.nodeName(); if (nodeName.equalsIgnoreCase(NodeTypes.MENTION.toString())) { if (node.attributes().hasKey(AttribTypes.UID.toString())) { String uid = node.attr(AttribTypes.UID.toString()); SymUser user = null; try { user = symClient.getUsersClient().getUserFromId(Long.parseLong(uid)); logger.info("Translated mention uid {} to email {}", uid, user.getEmailAddress()); } catch (UsersClientException e) { logger.error("Could not identify user email from id", e); } if (user != null && user.getEmailAddress() != null) { uid = user.getEmailAddress(); } Attribute emailAttribute = new Attribute(AttribTypes.EMAIL.toString(), uid); node.attributes().put(emailAttribute); node.removeAttr(AttribTypes.UID.toString()); } } updateMentionUidToEmail(symClient, node.childNodes()); } }