G
Guest
Hi
i am using following code which extracts information from XML file and creates an instance of class which it adds to hash table. problem is i am unable to extract information from hashtable : here is the piece of code
public void readEmailRecords()
XmlTextReader reader = new XmlTextReader("C:\\Mailer\\EmailRec.xml")
reader.MoveToElement();
try
while(reader.Read())
if(reader.HasAttributes && reader.NodeType==XmlNodeType.Element
reader.MoveToAttribute("Subject")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setSubject(reader.Value.Trim())
reader.MoveToAttribute("From")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setFrom(reader.Value.Trim())
reader.MoveToAttribute("To")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setTO(reader.Value.Trim())
reader.MoveToAttribute("CC")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setCC(reader.Value.Trim())
reader.MoveToAttribute("BCC")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setBCC(reader.Value.Trim())
reader.MoveToAttribute("DateTime")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setDateTime(reader.Value.Trim())
reader.MoveToAttribute("Body")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setBody(reader.Value.Trim())
if(!htMessages.ContainsKey(pm.GetHashCode())
htMessages.Add(pm.GetHashCode(), pm);
}
reader.Close()
reader=null
}
catch(Exception e) { MessageBox.Show(null,"XML Exception : " + e.ToString(),"Error");
private void frmMailer_Load(object sender, System.EventArgs e
pm = new PopMessage()
htMessages = new Hashtable()
readEmailRecords();
foreach(string c in htMessages.Keys
Console.WriteLine( ( (PopMessage) htMessages[c]).getFrom() )
Instead of printing value from getFrom(), it just prints a blank strin
NOTE : pm & htMessges are defined as a class member variable
Thanx in advanc
i am using following code which extracts information from XML file and creates an instance of class which it adds to hash table. problem is i am unable to extract information from hashtable : here is the piece of code
public void readEmailRecords()
XmlTextReader reader = new XmlTextReader("C:\\Mailer\\EmailRec.xml")
reader.MoveToElement();
try
while(reader.Read())
if(reader.HasAttributes && reader.NodeType==XmlNodeType.Element
reader.MoveToAttribute("Subject")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setSubject(reader.Value.Trim())
reader.MoveToAttribute("From")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setFrom(reader.Value.Trim())
reader.MoveToAttribute("To")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setTO(reader.Value.Trim())
reader.MoveToAttribute("CC")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setCC(reader.Value.Trim())
reader.MoveToAttribute("BCC")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setBCC(reader.Value.Trim())
reader.MoveToAttribute("DateTime")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setDateTime(reader.Value.Trim())
reader.MoveToAttribute("Body")
if( reader.Value.Trim() != "" || reader.Value.Trim() != null
pm.setBody(reader.Value.Trim())
if(!htMessages.ContainsKey(pm.GetHashCode())
htMessages.Add(pm.GetHashCode(), pm);
}
reader.Close()
reader=null
}
catch(Exception e) { MessageBox.Show(null,"XML Exception : " + e.ToString(),"Error");
private void frmMailer_Load(object sender, System.EventArgs e
pm = new PopMessage()
htMessages = new Hashtable()
readEmailRecords();
foreach(string c in htMessages.Keys
Console.WriteLine( ( (PopMessage) htMessages[c]).getFrom() )
Instead of printing value from getFrom(), it just prints a blank strin
NOTE : pm & htMessges are defined as a class member variable
Thanx in advanc