List of usage examples for org.jsoup.nodes Node childNode
public Node childNode(int index)
From source file:Main.java
private static void removeComments(Node node) { for (int i = 0; i < node.childNodes().size();) { Node child = node.childNode(i); if (child.nodeName().equals("#comment")) child.remove();// ww w . j av a2 s . c o m else { removeComments(child); i++; } } }
From source file:damo.three.ie.util.HtmlUtilities.java
private static void removeComments(Node node) { for (int i = 0; i < node.childNodes().size();) { Node child = node.childNode(i); if (child.nodeName().equals("#comment")) { child.remove();//from w w w . ja va 2s. c o m } else { removeComments(child); i++; } } }
From source file:com.zacwolf.commons.email.Email.java
public static void removeComments(org.jsoup.nodes.Node node) { for (int i = 0; i < node.childNodes().size(); i++) { org.jsoup.nodes.Node child = node.childNode(i); if (child.nodeName().equals("#comment")) child.remove();/* w ww. j av a 2 s .c o m*/ else removeComments(child); } }
From source file:org.coronastreet.gpxconverter.GarminForm.java
private static String findFlowKey(Node node) { String key = null;/* w ww. j a v a 2s.com*/ for (int i = 0; i < node.childNodes().size();) { Node child = node.childNode(i); if (child.nodeName().equals("#comment")) { //System.out.println(child.toString()); String flowKeyPattern = "\\<\\!-- flowExecutionKey\\: \\[(e1s1)\\] --\\>"; key = child.toString().replaceAll(flowKeyPattern, "$1").trim(); break; } else { findFlowKey(child); i++; } } return key; }
From source file:com.sfs.DataFilter.java
/** * Removes the comments./* w w w.ja v a 2 s . c om*/ * * @param node the node */ private static void removeComments(Node node) { for (int i = 0; i < node.childNodes().size();) { Node child = node.childNode(i); if (child.nodeName().equals("#comment")) child.remove(); else { removeComments(child); i++; } } }
From source file:sk.svec.jan.acb.extraction.DiscussionFinder.java
private boolean findDocumentParts(Node root) { Node node = root; int depth = 0; while (node != null) { if (node.nodeName().compareTo("#text") != 0) { HashMap<String, Integer> level = allLevels.get(depth); // System.out.println(depth + " " + allLevels.size()); if (level.containsKey(node.nodeName() + "[class=" + node.attr("class") + "]")) { Integer get = level.get(node.nodeName() + "[class=" + node.attr("class") + "]"); level.put(node.nodeName() + "[class=" + node.attr("class") + "]", get + 1); } else { level.put(node.nodeName() + "[class=" + node.attr("class") + "]", 1); }/*w w w. j a v a 2s .co m*/ } if (node.childNodeSize() > 0) { node = node.childNode(0); depth++; } else { while (node.nextSibling() == null && depth > 0) { node = node.parentNode(); depth--; } if (node == root) { break; } node = node.nextSibling(); } } //ak je 0 alebo 1 datum, vratime false, kedze sa to neda zistit if (dateCount < 2) { return false; } else { return findOnePart(dateCount); } }
From source file:sk.svec.jan.acb.extraction.DiscussionFinder.java
private void traversePage(Node root) { Node node = root; int depth = 0; while (node != null) { // System.out.println(depth + " " + node.nodeName() + " " + node.childNodeSize()); // if(node.attr("class").compareTo("contribution")==0){ // System.out.println(depth); // } if (maxDepth < depth) { maxDepth = depth;//from ww w. ja v a 2 s.com } boolean analyze = analyze(node); if (analyze) { break; } if (node.childNodeSize() > 0) { node = node.childNode(0); depth++; } else { while (node.nextSibling() == null && depth > 0) { node = node.parentNode(); depth--; } if (node == root) { break; } node = node.nextSibling(); } } }
From source file:sk.svec.jan.acb.extraction.DiscussionFinder.java
private boolean analyze(Node node) { // System.out.println(node.nodeName()); for (Attribute attribute : node.attributes().asList()) { String key = attribute.getKey(); String value = attribute.getValue(); // System.out.println(" attr:" + key + " value:" + value); if (!foundDateStringSwitch) { foundDateStringSwitch = findDate(node, value); }/* w w w . ja v a2 s .c o m*/ if (foundDateStringSwitch) { boolean foundDateString = findDate(node, value); if (foundDateString) { String child = node.childNode(0).toString(); foundDate = findDateValue(node, child); dateScore = 10; } } else { foundDate = findDateValue(node, value); dateScore = 5; } } return false; // return foundDate && foundAuthor && foundText; }
From source file:sk.svec.jan.acb.extraction.Finder.java
private void markBadText(Node root) { Node node = root; int depth = 0; while (node != null) { //ak sa jedna o text, ktory ma menej ako 15 znakov if (node.nodeName().compareTo("#text") == 0) { if (node.toString().trim().length() < 20) { nodesToRemove.add(node); // System.out.println(node); }//from w ww .java 2 s . c om } if (node.childNodeSize() > 0) { node = node.childNode(0); depth++; } else { while (node.nextSibling() == null && depth > 0) { node = node.parentNode(); depth--; } if (node == root) { break; } node = node.nextSibling(); } } }
From source file:sk.svec.jan.acb.extraction.Finder.java
public Node removeNodes(Node root, Node nodeToRemove) { Node node = root; Node ntr = nodeToRemove;//from ww w .j a va 2s. co m int depth = 0; while (node != null) { if (node.equals(ntr)) { node.remove(); return root; } if (node.childNodeSize() > 0) { node = node.childNode(0); depth++; } else { while (node.nextSibling() == null && depth > 0) { node = node.parentNode(); depth--; } if (node == root) { break; } node = node.nextSibling(); } } return root; }