XML Development

Moderators: None (Apply to moderate this forum)
Number of threads: 252
Number of posts: 451

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Xpath problem Posted by airwalker on 27 Jun 2006 at 3:16 PM
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();
xd.Load(xtr);
// Retrieve nodes to match the expression
XmlNodeList xnl = xd.DocumentElement.SelectNodes(txtXPath.Text);
// And dump the results
lbNodes.Items.Clear();
foreach (XmlNode xnod in xnl)
// For elements, display the corresponding text entity
if (xnod.NodeType == XmlNodeType.Element)
lbNodes.Items.Add(xnod.NodeType.ToString() + ": " +
xnod.Name + " = " + xnod.FirstChild.Value);
else
lbNodes.Items.Add(xnod.NodeType.ToString()+ ": " +
xnod.Name + " = " + xnod.Value);
xtr.Close();
}

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 =<undefined value>

any suggestions would be greatly appreciated.
Report
Re: Xpath problem Posted by airwalker on 28 Jun 2006 at 3:33 PM
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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.