Hallo

I have written the following source code to read out from a XML file; and actualle line which are between <Line> </LINE> .
The problem is when there are more than one line of <Line> </LINE> . in sequence I get just the first one, why!?

- <SPEECH>
<SPEAKER>MARCELLUS</SPEAKER>
<LINE>Horatio says 'tis but our fantasy,</LINE>
<LINE>That if again this apparition come,</LINE>
<LINE>He may approve our eyes and speak to it.</LINE>
</SPEECH>

Second problem that I'm facing is when I try to use the hash map to count the occurrences of the words, I get an error message for the command:
anInteger = new Integer(Integer.parseInt(anInteger + 1));

//"The operato + is undefined for the argument type Integer, int"

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import org.w3c.dom.Document;
import org.w3c.dom.*;
import java.util.StringTokenizer;
import java.util.Hashtable;
import java.util.Map;
import java.util.HashMap;
import java.util.WeakHashMap;
import java.util.TreeMap;
import java.util.Iterator;
import java.lang.Integer;


public class HAMLET {
public static void main(String[] args) {
Map map = new HashMap(); // hash table
map = new TreeMap();

//open the file and read the "LINE" lines
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File("c:/hamlet.xml"));
doc.getDocumentElement ().normalize ();
NodeList listOfLines = doc.getElementsByTagName("SPEECH");
int r = listOfLines.getLength();
for(int s=0; s<listOfLines.getLength() ; s++){
Node firstLineNode = listOfLines.item(s);
if(firstLineNode.getNodeType() == Node.ELEMENT_NODE){
Element firstLineElement = (Element)firstLineNode;
NodeList firstNameList = firstLineElement.getElementsByTagName("LINE");
Element firstNameElement = (Element)firstNameList.item(0);
NodeList textFNList = firstNameElement.getChildNodes();
String LineofFile = ((Node)textFNList.item(0)).getNodeValue().trim();
word_by_word_extraction linedecom = new word_by_word_extraction();
String wordsofline[] = linedecom.wordextraction(LineofFile);
int numwordline = wordsofline.length;
for(int gh = 0; gh><numwordline; gh++)
{

//PorterStemmer is a function which gives back the stemm of a string
PorterStemmer termto = new PorterStemmer();
String returenedterm = termto.stem(wordsofline[gh]);
// ubdating the hash MAP
Integer anInteger ;
StringTokenizer st = new StringTokenizer(returenedterm);
if (map.containsKey(returenedterm)) // key already in Map
{
anInteger = (Integer)map.get(returenedterm);
//"The operato + is undefined for the argument type Integer, int"
anInteger = new Integer(Integer.parseInt(anInteger + 1));
}
else // key doesn't exist yet.
{
// Create new integer indicating one occurrence.
anInteger = new Integer(1);
}
}
}
}
}
catch (Throwable t) {
t.printStackTrace ();
}
// writing out the hash table
Iterator it = map.keySet().iterator();
while (it.hasNext()) {
String s = (String) it.next();
System.out.println(map.get(s) + "\t" + s);
}
}>