I'm using the following snippet of code to try and locate all instances of ul and ol elements in an XHTML document. I want to perform operations only on those ul and ol lists that are NOT embedded within another list.
I keep getting the null pointer error seen below when I run this code. Is there something wrong with my XPath expression that is causing this problem, or it possible that there is something weird, like an empty <ul></ul> in my document??? Thanks!! List lists = document.selectNodes( "//ul | //ol" ); for (int i=0; i < lists.size(); i++) { Element list = (Element)lists.get(i); List nodes = list.selectNodes("ancestor::ul"); if ((nodes != null) && (nodes.size() > 0)) { continue; } nodes = list.selectNodes("ancestor::ol"); if ((nodes != null) && (nodes.size() > 0)) { continue; } // do something with the list elements } java.lang.NullPointerException at org.jaxen.dom4j.DocumentNavigator.getParentAxisIterator(DocumentNavigator.ja va:150) at org.jaxen.util.AncestorAxisIterator.createIterator(AncestorAxisIterator.java :28) at org.jaxen.util.StackedIterator.internalCreateIterator(StackedIterator.java:5 7) at org.jaxen.util.StackedIterator.next(StackedIterator.java:82) at org.jaxen.expr.DefaultLocationPath.evaluate(DefaultLocationPath.java:139) at org.jaxen.expr.DefaultXPath.asList(DefaultXPath.java:46) at org.jaxen.JaXPath.jaSelectNodes(JaXPath.java:35) at org.jaxen.BaseXPath.selectNodes(BaseXPath.java:22) at org.dom4j.xpath.DefaultXPath.selectNodes(DefaultXPath.java:122) at org.dom4j.tree.AbstractNode.selectNodes(AbstractNode.java:164) at com.finaltouch.xml.editor.io.TableListFilter.run(TableListFilter.java:47) at java.lang.Thread.run(Thread.java:484) _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user