1 19 20 package com.hp.hpl.jena.util.xml; 23 24 25 import java.util.*; 28 29 import org.w3c.dom.*; 30 31 32 40 public class SimpleXMLPathElement 41 implements SimpleXMLPathComponent 42 { 43 46 47 public static final String ALL_CHILDREN = "*"; 48 49 50 53 56 57 protected String m_elemName; 58 59 60 63 68 public SimpleXMLPathElement( String elemName ) { 69 m_elemName = elemName; 70 } 71 72 73 77 public SimpleXMLPathElement() { 78 m_elemName = ALL_CHILDREN; 79 } 80 81 82 85 92 public Iterator getAll( Node node ) { 93 if (!(node instanceof Element)) { 95 throw new IllegalArgumentException ( "Tried to get element " + m_elemName + " from a parent node of type " + node.getClass().getName() ); 96 } 97 98 return new NodeListIterator( ((Element) node).getElementsByTagName( m_elemName ) ); 99 } 100 101 107 public Object getFirst( Node node ) { 108 return getAll( node ).next(); 109 } 110 111 112 115 119 } 120 121 122 148 | Popular Tags |