public static Element[] getPrecedingSiblings(Element element, String namespaceUri, String localName) { List childElements = new ArrayList(); Element parent = (Element) element.getParentNode(); Element[] children = getChildren(parent, namespaceUri, localName);  int i = 0; while (children[i] != element && i < children.length) { childElements.add(children[i]); i++; }  return (Element[]) childElements.toArray(new Element[childElements.size()]);
public static Element[] getPrecedingSiblings(Element element, String namespaceUri) { return getPrecedingSiblings(element, namespaceUri, "*");
    public static Element[] getPrecedingSiblings(Element element, String namespaceUri,            String localName) {        List childElements = new ArrayList();        Element parent = (Element) element.getParentNode();        Element[] children = getChildren(parent, namespaceUri, localName);        int i = 0;        while (children[i] != element && i < children.length) {            childElements.add(children[i]);            i++;        }        return (Element[]) childElements.toArray(new Element[childElements.size()]);    }