public static Element getOnlyChildElement(NodeList list) throws XMLRPCException {

		Element e = null;
		Node n;
		for(int i = 0; i < list.getLength(); i++) {
			n = list.item(i);
			// Strip only whitespace text elements and comments
			if((n.getNodeType() == Node.TEXT_NODE
						&& n.getNodeValue().trim().length() <= 0)
					|| n.getNodeType() == Node.COMMENT_NODE)
				continue;

			// Check if there is anything else than an element node.
			if(n.getNodeType() != Node.ELEMENT_NODE) {
				throw new XMLRPCException("Only element nodes allowed.");
			}

			// If there was already an element, throw exception.
			if(e != null) {
				throw new XMLRPCException("Element has more than one children.");
			}

			e = (Element)n;

		}

		return e;

	}
public static Element getOnlyChildElement ( NodeList list ) throws XMLRPCException { Element e = null ; Node n ; for ( int i = 0 ; i < list . getLength ( ) ; i ++ ) { n = list . item ( i ) ; if ( ( n . getNodeType ( ) == Node . TEXT_NODE && n . getNodeValue ( ) . trim ( ) . length ( ) <= 0 ) || n . getNodeType ( ) == Node . COMMENT_NODE ) continue ; if ( n . getNodeType ( ) != Node . ELEMENT_NODE ) { throw new XMLRPCException ( "Only element nodes allowed." ) ; } if ( e != null ) { throw new XMLRPCException ( "Element has more than one children." ) ; } e = ( Element ) n ; } return e ; }
Returns the only child element in a given NodeList.
Will throw an error if there is more then one child element or any other
child that is not an element or an empty text string (whitespace are normal).

@param list A NodeList of children nodes.
@return The only child element in the given node list.
@throws XMLRPCException Will be thrown if there is more then one child element
except empty text nodes.