I can read the file. from the web server. The problem I'm having is reading the contents of the xml file. I wish msdn.com forums was easy to find what forum I need. So I know this is not in the right forum.
I keep getting a cashing error. I know what that is, I just don't know how to fix it.
for some reason it errors out. my code is below.
try { xmlDoc.Load(url); } catch (XmlException ee) { MessageBox.Show(ee.Message,Application.ProductName); return; } //System.Xml.XmlNodeList NodeList = xmlDoc.GetElementsByTagName("admin"); foreach (XmlNodeList NodeList in xmlDoc.GetElementsByTagName("admin")) // This is where the error is { string alias = NodeList[0].FirstChild.ChildNodes[0].InnerText; string real = NodeList[0].FirstChild.ChildNodes[1].InnerText; string auth = NodeList[0].FirstChild.ChildNodes[2].InnerText; if (real == RealName) { if (auth == "Approved") { break; } else { MessageBox.Show("Your are not allowed admin access?",Application.ProductName); //Properties.Settings.Default.AdminOn = false; //Properties.Settings.Default.AdminCode = ""; //Properties.Settings.Default.Save(); //this.Close(); } }
I added the exception error below.
System.InvalidCastException was unhandled
HResult=-2147467262
Message=Unable to cast object of type 'System.Xml.XmlElement' to type 'System.Xml.XmlNodeList'.