1 16 17 package org.apache.html.dom; 18 19 import org.apache.xerces.dom.DeepNodeListImpl; 20 import org.apache.xerces.dom.ElementImpl; 21 import org.apache.xerces.dom.NodeImpl; 22 import org.w3c.dom.Node ; 23 import org.w3c.dom.NodeList ; 24 25 35 public class NameNodeListImpl 36 extends DeepNodeListImpl 37 implements NodeList { 38 39 40 41 public NameNodeListImpl(NodeImpl rootNode, String tagName) { 42 super( rootNode, tagName ); 43 } 44 45 46 51 protected Node nextMatchingElementAfter(Node current) { 52 53 Node next; 54 while (current != null) { 55 if (current.hasChildNodes()) { 57 current = (current.getFirstChild()); 58 } 59 60 else if (current != rootNode && null != (next = current.getNextSibling())) { 62 current = next; 63 } 64 65 else { 67 next = null; 68 for (; current != rootNode; current = current.getParentNode()) { 70 71 next = current.getNextSibling(); 72 if (next != null) 73 break; 74 } 75 current = next; 76 } 77 78 if (current != rootNode && current != null 81 && current.getNodeType() == Node.ELEMENT_NODE ) { 82 String name = ((ElementImpl) current).getAttribute( "name" ); 83 if ( name.equals("*") || name.equals(tagName)) 84 return current; 85 } 86 87 } 89 90 return null; 92 93 } 95 } | Popular Tags |