Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
Hi, I got a problem with some xml code. In quite certain the error is easily solved, but I just dont know how as im new to xml.
The code im using is to enter an XPath statement into a text box on a windows form.
private void btnEvaluate_Click(object sender, System.EventArgs e)
// Load the Books.xml file
XmlTextReader xtr = new XmlTextReader(@"....Books.xml");
xtr.WhitespaceHandling = WhitespaceHandling.None;
XmlDocument xd = new XmlDocument();
// Retrieve nodes to match the expression
XmlNodeList [green][b]xnl[/b][/green] = xd.DocumentElement.SelectNodes(txtXPath.Text);
// And dump the results
foreach (XmlNode xnod in [green][b]xnl[/b][/green])
// For elements, display the corresponding text entity
if (xnod.NodeType == XmlNodeType.Element)
lbNodes.Items.Add(xnod.NodeType.ToString() + ": " +
xnod.Name + " = " + xnod.FirstChild.Value);
lbNodes.Items.Add(xnod.NodeType.ToString()+ ": " +
xnod.Name + " = " + xnod.Value);
when I execute the program and enter an XPath statement in the text box I get this error message:
"An unhandled exception of type 'System.Xml.XmlException' occurred in system.xml.dll Additional information: System error."
also when I put the mouse curser over the green text I get this message:
any suggestions would be greatly appreciated.
0 · ·