By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,885 Members | 1,300 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,885 IT Pros & Developers. It's quick & easy.

An unhandled exception of type 'System.Xml.Xsl.XsltException' occu

P: n/a
one
Hi, can some experts out there tell me why I am getting:
An unhandled exception of type 'System.Xml.Xsl.XsltException' occurred in system.xml.dll... (No details in the error dialog box)

FileStream fs = new FileStream("test.xml",FileMode.OpenOrCreate);
StreamReader sr = new StreamReader(fs);
XmlTextReader xtr = new XmlTextReader(sr);
XmlDocument xd = new XmlDocument();
xd.Load(xtr);
XmlElement root = xd.DocumentElement;
XmlNamespaceManager ns = new XmlNamespaceManager(xd.NameTable);
ns.AddNamespace("soap", @"http://schemas.xmlsoap.org/soap/envelope/");
string temp = @"soap:Envelope/soap:Body/test:TestMessage/test:Body/test:Text";
XmlNodeList nl = root.SelectNodes(temp, ns); <---- This line throw the exception.

I am thinking maybe the dotnet framework doesn't like the colon in the XPath? Has anyone seen this before?
Or is it because I have two namespaces (i.e. 'soap' and 'test')?
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
one wrote:
Hi, can some experts out there tell me why I am getting:
An unhandled exception of type 'System.Xml.Xsl.XsltException' occurred in system.xml.dll... (No details in the error dialog box)

FileStream fs = new FileStream("test.xml",FileMode.OpenOrCreate);
StreamReader sr = new StreamReader(fs);
XmlTextReader xtr = new XmlTextReader(sr);
XmlDocument xd = new XmlDocument();
xd.Load(xtr);
XmlElement root = xd.DocumentElement;
XmlNamespaceManager ns = new XmlNamespaceManager(xd.NameTable);
ns.AddNamespace("soap", @"http://schemas.xmlsoap.org/soap/envelope/");
You should aslo add a namespace binding for "test" namespace prefix.
string temp = @"soap:Envelope/soap:Body/test:TestMessage/test:Body/test:Text";


--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2

P: n/a
one wrote:
Hi, can some experts out there tell me why I am getting:
An unhandled exception of type 'System.Xml.Xsl.XsltException' occurred in system.xml.dll... (No details in the error dialog box)

FileStream fs = new FileStream("test.xml",FileMode.OpenOrCreate);
StreamReader sr = new StreamReader(fs);
XmlTextReader xtr = new XmlTextReader(sr);
XmlDocument xd = new XmlDocument();
xd.Load(xtr);
XmlElement root = xd.DocumentElement;
XmlNamespaceManager ns = new XmlNamespaceManager(xd.NameTable);
ns.AddNamespace("soap", @"http://schemas.xmlsoap.org/soap/envelope/");
You should aslo add a namespace binding for "test" namespace prefix.
string temp = @"soap:Envelope/soap:Body/test:TestMessage/test:Body/test:Text";


--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.