I have Problem Reading XML and using dictionary to store all tags and their values.I have used this code in VB.Net without problem. It fails while "adding the tag as the key and the tag's value as the value"
public class ConfigReader {
IDictionary dict;
public LoginConfigReader()
{
dict = new SortedList();
string myXmlFile = null;
myXmlFile = HostingEnvironment.ApplicationPhysicalPath + "App_Data\\myxmlfile.xml";
XmlTextReader reader = new XmlTextReader(myXmlFile);
reader.WhitespaceHandling = WhitespaceHandling.None;
reader.Read();
reader.Read();
while ((!reader.EOF))
{
if (!reader.IsStartElement())
{
break;
}
dict.Add(reader.Name, reader.ReadElementString);
}
reader.Close();
}