org.jsoup.nodes.Node#childNode ( )源码实例Demo

下面列出了org.jsoup.nodes.Node#childNode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Asqatasun   文件: HTMLJsoupCleanerImpl.java
/**
 * Remove the comments of the page 
 * 
 * @param node 
 */
private void removeMalformedAttributes(Node node) {
    // as we are removing child nodes while iterating, we cannot use a normal foreach over children,
    // or will get a concurrent list modification error.
    int i = 0;
    while (i < node.childNodes().size()) {
        Node child = node.childNode(i);
        for (Attribute attr : child.attributes()) {
            if (attr.getKey().startsWith("\"") && attr.getKey().endsWith("\"")) {
                child.removeAttr(attr.getKey());
            }
        }
        removeMalformedAttributes(child);
        i++;
    }
}
 
源代码2 项目: astor   文件: NodeTraversor.java
/**
 * Start a depth-first traverse of the root and all of its descendants.
 * @param root the root node point to traverse.
 */
public void traverse(Node root) {
    Node node = root;
    int depth = 0;
    
    while (node != null) {
        visitor.head(node, depth);
        if (node.childNodeSize() > 0) {
            node = node.childNode(0);
            depth++;
        } else {
            while (node.nextSibling() == null && depth > 0) {
                visitor.tail(node, depth);
                node = node.parentNode();
                depth--;
            }
            visitor.tail(node, depth);
            if (node == root)
                break;
            node = node.nextSibling();
        }
    }
}
 
源代码3 项目: astor   文件: NodeTraversor.java
/**
 * Start a depth-first traverse of the root and all of its descendants.
 * @param visitor Node visitor.
 * @param root the root node point to traverse.
 */
public static void traverse(NodeVisitor visitor, Node root) {
    Node node = root;
    int depth = 0;
    
    while (node != null) {
        visitor.head(node, depth);
        if (node.childNodeSize() > 0) {
            node = node.childNode(0);
            depth++;
        } else {
            while (node.nextSibling() == null && depth > 0) {
                visitor.tail(node, depth);
                node = node.parentNode();
                depth--;
            }
            visitor.tail(node, depth);
            if (node == root)
                break;
            node = node.nextSibling();
        }
    }
}
 
源代码4 项目: astor   文件: NodeTraversor.java
/**
 * Start a depth-first traverse of the root and all of its descendants.
 * @param visitor Node visitor.
 * @param root the root node point to traverse.
 */
public static void traverse(NodeVisitor visitor, Node root) {
    Node node = root;
    int depth = 0;
    
    while (node != null) {
        visitor.head(node, depth);
        if (node.childNodeSize() > 0) {
            node = node.childNode(0);
            depth++;
        } else {
            while (node.nextSibling() == null && depth > 0) {
                visitor.tail(node, depth);
                node = node.parentNode();
                depth--;
            }
            visitor.tail(node, depth);
            if (node == root)
                break;
            node = node.nextSibling();
        }
    }
}
 
源代码5 项目: jsoup-learning   文件: NodeTraversor.java
/**
 * Start a depth-first traverse of the root and all of its descendants.
 * @param root the root node point to traverse.
 */
public void traverse(Node root) {
    Node node = root;
    int depth = 0;
    
    while (node != null) {
        visitor.head(node, depth);
        if (node.childNodeSize() > 0) {
            node = node.childNode(0);
            depth++;
        } else {
            while (node.nextSibling() == null && depth > 0) {
                visitor.tail(node, depth);
                node = node.parent();
                depth--;
            }
            visitor.tail(node, depth);
            if (node == root)
                break;
            node = node.nextSibling();
        }
    }
}
 
源代码6 项目: Asqatasun   文件: HTMLJsoupCleanerImpl.java
/**
 * Remove the comments of the page 
 * 
 * @param node 
 */
private void removeComments(Node node) {
    // as we are removing child nodes while iterating, we cannot use a normal foreach over children,
    // or will get a concurrent list modification error.
    int i = 0;
    while (i < node.childNodes().size()) {
        Node child = node.childNode(i);
        if (child.nodeName().equals("#comment"))
            child.remove();
        else {
            removeComments(child);
            i++;
        }
    }
}
 
源代码7 项目: flow   文件: JsoupUtils.java
/**
 * Removes all comments from the {@code node} tree.
 *
 * @param node
 *            a Jsoup node
 */
static void removeCommentsRecursively(Node node) {
    int i = 0;
    while (i < node.childNodeSize()) {
        Node child = node.childNode(i);
        if (child instanceof Comment) {
            child.remove();
        } else {
            removeCommentsRecursively(child);
            i++;
        }
    }
}