Листинг 8.11. Метод findNodes класса NewsFormatter (NewsFormatter.java)
// locate the nodes that are Elements for text data private void findNodes( Element ne ){ NodeList nl = ne.getChildNodes(); // all nodes int ct = nl.getLength(); nodeHash = new Hashtable( 2 * ct ); for( int i = 0 ; i < ct ; i++ ){ Node n = nl.item(i); if( n instanceof Element ){ nodeHash.put( n.getNodeName(), n ); } } }
Заголовки и краткая версия сообщения всегда снабжаются ссылкой на полную версию. Эта ссылка встраивается в HTML-страницу с помощью методов doNewsItemHead и doNewsItemShort, как показано в листинге 8.12.