I have two queries that appear to be exactly the same, but one of them
returns null while the other one returns a valid result!
Can anyone provide an explanation to why this is so? Below is an nunit
test that exposes the problem. I have run the test under both the 1.0
and 1.1 framework with the same result.
[Test]
public void XPathBooks()
{
XmlDocument smallDoc = new XmlDocument();
smallDoc.LoadXm l("<book><title >Bugs</title></book>");
XmlNode book1 = smallDoc.Select SingleNode(@"bo ok");
XmlNode title1 = book1.SelectSin gleNode(@"/book/title");
Assert.IsNotNul l(title1, "title1");
XmlDocument largeDoc = new XmlDocument();
largeDoc.LoadXm l("<books><book ><title>Bugs</title></book></books>");
XmlNode book2 = largeDoc.Select SingleNode(@"bo oks/book");
Assert.AreEqual (book1.OuterXml , book2.OuterXml) ;
XmlNode title2 = book2.SelectSin gleNode(@"/book/title");
Assert.IsNotNul l(title2, "title2"); // This test fails!!
}
Thanks,
Rune