Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Xpath problem

airwalkerairwalker Member Posts: 71
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:

"xnl =

any suggestions would be greatly appreciated.


  • airwalkerairwalker Member Posts: 71
    I found the solution, I had one too many closing tags in my xml file, it was right down at the end of the page, so far down i didnt see it lol.
Sign In or Register to comment.