public static String getOneNodeVal ( final Node el , final String name ) throws SAXException { /* We expect one child of type text */ if ( ! el . hasChildNodes ( ) ) { return null ; } NodeList children = el . getChildNodes ( ) ; if ( children . getLength ( ) > 1 ) { throw new SAXException ( "Multiple property values: " + name ) ; } Node child = children . item ( 0 ) ; return child . getNodeValue ( ) ; }
Get the value of an element . We expect 0 or 1 child nodes . For no child node we return null for more than one we raise an exception .