Hi,
I cannot guess, why some XPath expressions in my code returns false and some
even errors, while the others returne true as I expected. I'am workin with VS
2008 Express Edition.
Dim xEl As XElement = <root><child1>< child2/></child1></root>
Dim nav As XPathNavigator = xEl.CreateNavig ator
nav.MoveToRoot( )
Console.WriteLi ne(nav.Matches( "*")) 'returns FALSE
Console.WriteLi ne(nav.Matches( "root")) 'returns FALSE
Console.WriteLi ne(nav.Matches( "/root")) 'returns FALSE
Console.WriteLi ne("--------------------------")
nav.MoveToFirst Child()
Console.WriteLi ne(nav.Matches( "*")) 'OK, returns TRUE
Console.WriteLi ne(nav.Matches( "child1")) 'OK, returns TRUE
Console.WriteLi ne(nav.Matches( "child1[parent::root]")) 'OK, returns TRUE
Console.WriteLi ne(nav.Matches( "//root/child1")) 'returns FALSE
Console.WriteLi ne(nav.Matches( "*[self::child1]")) 'OK, returns TRUE
'Console.WriteL ine(nav.Matches ("self::child1" )) 'raise error
'Console.WriteL ine(nav.Matches ("*/self::child1")) 'raise error
Console.ReadLin e()
I cannot guess, why some XPath expressions in my code returns false and some
even errors, while the others returne true as I expected. I'am workin with VS
2008 Express Edition.
Dim xEl As XElement = <root><child1>< child2/></child1></root>
Dim nav As XPathNavigator = xEl.CreateNavig ator
nav.MoveToRoot( )
Console.WriteLi ne(nav.Matches( "*")) 'returns FALSE
Console.WriteLi ne(nav.Matches( "root")) 'returns FALSE
Console.WriteLi ne(nav.Matches( "/root")) 'returns FALSE
Console.WriteLi ne("--------------------------")
nav.MoveToFirst Child()
Console.WriteLi ne(nav.Matches( "*")) 'OK, returns TRUE
Console.WriteLi ne(nav.Matches( "child1")) 'OK, returns TRUE
Console.WriteLi ne(nav.Matches( "child1[parent::root]")) 'OK, returns TRUE
Console.WriteLi ne(nav.Matches( "//root/child1")) 'returns FALSE
Console.WriteLi ne(nav.Matches( "*[self::child1]")) 'OK, returns TRUE
'Console.WriteL ine(nav.Matches ("self::child1" )) 'raise error
'Console.WriteL ine(nav.Matches ("*/self::child1")) 'raise error
Console.ReadLin e()
Comment