public static void printDom ( Node n , String prefix ) { String outString = prefix ; if ( n . getNodeType ( ) == Node . TEXT_NODE ) { outString += "'" + n . getTextContent ( ) . trim ( ) + "'" ; } else { outString += n . getNodeName ( ) ; } System . out . println ( outString ) ; NodeList children = n . getChildNodes ( ) ; int length = children . getLength ( ) ; for ( int i = 0 ; i < length ; i ++ ) { FacebookXmlRestClient . printDom ( children . item ( i ) , prefix + " " ) ; } }
Prints out the DOM tree .