Code example for Node

Methods: getFirstChild, getNodeValue

0
 
    /** Get the content of a node 
     */ 
    public static String getContent(Node n ) {
        if( n==null ) return null;
        Node n1=n.getFirstChild();
        // XXX Check if it's a text node 
 
        String s1=n1.getNodeValue();
        return s1.trim();
    } 
     
    /** Get the first child 
     */ 
    public static Node getChild( Node parent, String name ) {
        if( parent==null ) return null;
        Node first=parent.getFirstChild();
        if( first==null ) return null;
        for (Node node = first; node != null;
             node = node.getNextSibling()) {
            //System.out.println("getNode: " + name + " " + node.getNodeName());