Methods Summary |
---|
public static org.w3c.dom.Element | getFirstElement(org.w3c.dom.Element element, java.lang.String name)
NodeList nl = element.getElementsByTagName( name );
if ( nl.getLength() < 1 )
throw new RuntimeException(
"Element: "+element+" does not contain: "+name);
return (Element)nl.item(0);
|
public static java.lang.String | getSimpleElementText(org.w3c.dom.Element node, java.lang.String name)
Element namedElement = getFirstElement( node, name );
return getSimpleElementText( namedElement );
|
public static java.lang.String | getSimpleElementText(org.w3c.dom.Element node)
StringBuffer sb = new StringBuffer();
NodeList children = node.getChildNodes();
for(int i=0; i<children.getLength(); i++) {
Node child = children.item(i);
if ( child instanceof Text )
sb.append( child.getNodeValue() );
}
return sb.toString();
|