List of usage examples for org.w3c.dom Node getNextSibling
public Node getNextSibling();
From source file:Main.java
public static Element getNextElement(Node el) { while ((el != null) && (el.getNodeType() != Node.ELEMENT_NODE)) { el = el.getNextSibling(); }//from w ww . j a v a2s . co m return (Element) el; }
From source file:Main.java
/** * Gets the next sibling to the given element with the given name. * * @return the next sibling, or null if no such sibling *//*from w w w . j a v a 2 s. c o m*/ public static Element getSiblingNamed(Element element, String name) { if (element == null) { return null; } Node node = element; while (true) { node = node.getNextSibling(); if (node == null) { return null; } if (!(node instanceof Element)) { continue; } if (name.equals(node.getNodeName())) { return (Element) node; } } }
From source file:Main.java
public static Element GetFirstElementChild(Element tag) { Node n = tag.getFirstChild(); while (n.getNodeType() != Node.ELEMENT_NODE) { n = n.getNextSibling(); }/*w w w .j a v a 2s .c o m*/ Element e = (Element) n; return e; }
From source file:Main.java
/** *///from w w w .jav a 2 s . com public static Node getNext(Node current, String name, int type) { Node first = current.getNextSibling(); if (first == null) return null; for (Node node = first; node != null; node = node.getNextSibling()) { if (type >= 0 && node.getNodeType() != type) continue; //System.out.println("getNode: " + name + " " + node.getNodeName()); if (name == null) return node; if (name.equals(node.getNodeName())) { return node; } } return null; }
From source file:Main.java
/** * Gets the next sibling to the given element with the given attribute. * * @return the next sibling, or null if no such sibling *///from w w w.jav a2 s . c o m public static Element getSiblingWithAttribute(Element element, String attributeName) { if (element == null) { return null; } Node node = element; while (true) { node = node.getNextSibling(); if (node == null) { return null; } if (!(node instanceof Element)) { continue; } Element nextSibling = (Element) node; if (nextSibling.hasAttribute(attributeName)) { return nextSibling; } } }
From source file:Main.java
public static Element getNextSiblingElement(Node node) { if (node == null) return null; Node nextSibling = node.getNextSibling(); while ((nextSibling != null) && (nextSibling.getNodeType() != Node.ELEMENT_NODE)) nextSibling = nextSibling.getNextSibling(); if ((nextSibling != null) && (nextSibling.getNodeType() == Node.ELEMENT_NODE)) return (Element) nextSibling; return null;/*from w w w . ja va 2 s .co m*/ }
From source file:Main.java
public static Node getNext(Node current, String name, int type) { Node next = current.getNextSibling(); if (next == null) return null; for (Node node = next; node != null; node = node.getNextSibling()) { if (type >= 0 && node.getNodeType() != type) { continue; } else {//from w w w .ja v a 2s. c om if (name == null) { return node; } if (name.equals(node.getNodeName())) { return node; } } } return null; }
From source file:Main.java
public static Element getNextElement(Node el) { Node node = el; while (node != null && node.getNodeType() != Node.ELEMENT_NODE) { node = node.getNextSibling(); }/* w ww.ja va 2 s. co m*/ return (Element) node; }
From source file:Main.java
public static Element getNextChildElement(Node node) { Node n = node.getFirstChild(); while (n != null && n.getNodeType() != Node.ELEMENT_NODE) { n = n.getNextSibling(); }/*from w w w. j a v a 2 s.c o m*/ return (Element) n; }
From source file:Utils.java
/** * Get the first child of the specified type. * //from w w w. j a va 2 s. c o m * @param parent * @param type * @return */ public static Node getChild(Node parent, int type) { Node n = parent.getFirstChild(); while (n != null && type != n.getNodeType()) { n = n.getNextSibling(); } if (n == null) { return null; } return n; }