XML Loading Problem
-
Does anyone have any clues as to why I would get an "Unhandled Exception of type 'System.Xml.XmlException'" with the following code sniplet? It just says "Additional information: System Error". What is weird is that the error occurs on the red line and does not throw an exception based on my code (It comes from the IDE). Am I missing something blatant here?
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("XMLTree.xml");
try
{
XmlNodeList xmlnodeList = xmlDoc.SelectNodes("categories");
foreach(XmlNode x in xmlnodeList)
{
MessageBox.Show(x.InnerText);}
}
catch(System.Xml.XmlException e)
{
MessageBox.Show(e.Message + "\n\n" + e.StackTrace);
}-Nick Parker
-
Does anyone have any clues as to why I would get an "Unhandled Exception of type 'System.Xml.XmlException'" with the following code sniplet? It just says "Additional information: System Error". What is weird is that the error occurs on the red line and does not throw an exception based on my code (It comes from the IDE). Am I missing something blatant here?
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("XMLTree.xml");
try
{
XmlNodeList xmlnodeList = xmlDoc.SelectNodes("categories");
foreach(XmlNode x in xmlnodeList)
{
MessageBox.Show(x.InnerText);}
}
catch(System.Xml.XmlException e)
{
MessageBox.Show(e.Message + "\n\n" + e.StackTrace);
}-Nick Parker
your mistake is:
xmlDoc.LoadXml("XMLTree.xml");
you wantxmlDoc.Load("XMLTree.xml");
currently your code thinks that "XMLTre.xml" is xml source ;P
"When the only tool you have is a hammer, a sore thumb you will have."
-
Does anyone have any clues as to why I would get an "Unhandled Exception of type 'System.Xml.XmlException'" with the following code sniplet? It just says "Additional information: System Error". What is weird is that the error occurs on the red line and does not throw an exception based on my code (It comes from the IDE). Am I missing something blatant here?
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("XMLTree.xml");
try
{
XmlNodeList xmlnodeList = xmlDoc.SelectNodes("categories");
foreach(XmlNode x in xmlnodeList)
{
MessageBox.Show(x.InnerText);}
}
catch(System.Xml.XmlException e)
{
MessageBox.Show(e.Message + "\n\n" + e.StackTrace);
}-Nick Parker
-
your mistake is:
xmlDoc.LoadXml("XMLTree.xml");
you wantxmlDoc.Load("XMLTree.xml");
currently your code thinks that "XMLTre.xml" is xml source ;P
"When the only tool you have is a hammer, a sore thumb you will have."
Philip Fitzsimons wrote: currently your code thinks that "XMLTre.xml" is xml source :-O Thanks, that did it. :) -Nick Parker