Can anybody tell me why navigating xml with an instruction fails :
StringBuilder sb2 = new System.Text.StringBuilder();
XmlDocument doc = new XmlDocument( );
// --- XML without instruction -> Parsing succeeds
sb1.AppendLine( @"<MetalQuote>");
sb1.AppendLine( @"<Outcome>Success</Outcome>");
sb1.AppendLine( @"<Ask>1073.3</Ask>");
sb1.AppendLine( @"</MetalQuote>");
doc.LoadXml( sb1.ToString( ));
System.Diagnostics.Debug.WriteLine( doc.SelectSingleNode( "//MetalQuote/Outcome").InnerText);
This works well, but the same XML with an instruction fails :
// --- XML with instruction -> Parsing fails
sb2.AppendLine( @"<MetalQuote xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns=""http://www.xignite.com/services"" >");
sb2.AppendLine( @"<Outcome>Success</Outcome>");
sb2.AppendLine( @"<Ask>1073.3</Ask>");
sb2.AppendLine( @"</MetalQuote>");
doc.LoadXml( sb2.ToString( ));
System.Diagnostics.Debug.WriteLine( doc.SelectSingleNode( "//MetalQuote/Outcome").InnerText);
I get an exception at the doc.SelectSingleNode statement.