Hashtable problem
Hi
I have a small problem with hashtable. I have wirtten one hashtable method and put 2 values into hashtable.
Now i want to call the method and return 2 values from the method.
i dont know how to return the values from the method.
here i put the code.
-
import java.io.File;
import org.w3c.dom.Document;
import org.w3c.dom.*;
import java.util.*;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
publicclass XMLFile{
public Hashtable xmlData()
{
String repname="";
String magicname ="";
try{
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse (new File("magicFileMap.xml"));
NodeList children = doc.getElementsByTagName("DATAMAP");
Node child = children.item(0);
if(child !=null)
{
NamedNodeMap atts = child.getAttributes();
Node report = atts.getNamedItem("REPORTNAME" );
System.out.println("Report name:\t" + report.getNodeValue());
repname = report.getNodeValue();
Node report1 = atts.getNamedItem("MAGICNAME" );
System.out.println("MagicFile name:\t" + report1.getNodeValue() );
magicname = report1.getNodeValue();
}
Hashtable hashtable =new Hashtable ( ) ;
hashtable.put ("2",repname ) ;
hashtable.put ("1",magicname ) ;
Enumerationenum = hashtable.keys ( ) ;
String values="";
int i=1;
while ( enum.hasMoreElements ( ) ){
values = ( String ) enum.nextElement ( ) ;
System.out.println (" "+i+" ) key ="+values+", value ="+hashtable.get ( values ) ) ;
i++;
}
return hashtable;
}// End of try
catch(Exception e){
System.out.println("Value Error"+e.getMessage());
e.printStackTrace();
}
}
publicstaticvoid main ( String args[]){
XMLFile obj =new XMLFile();
System.out.println("Hai");
obj.xmlData();
}
}
Please any one help me how can i get the values from the hashtable.
Thanks
Merlin Roshina

