PRB: XPath Query Returns Unexpected Data (285163)
The information in this article applies to:
- Microsoft XML 2.0
- Microsoft XML 2.5
- Microsoft XML 2.6
- Microsoft XML 3.0
- Microsoft XML 4.0
This article was previously published under Q285163 SYMPTOMS
When you execute an XPath query similar to either of the following, the expected data may not be returned:
book/title[0]
book/title[1]
The first query is actually querying for the set of the first title nodes for each book node. The second query is also querying the set of all the second title nodes for each book node. In order to find instances of title nodes that occur under a specified book node, the queries should be as follows:
(book/title)[0]
(book/title)[1]
This is because of operator precedence, which, by default, associates the index qualifier with the title rather than the book/title path. The use of parentheses forces the index qualifier to be associated with all book/title nodes.
RESOLUTION
To resolve problems such as this with XPath queries, verify the syntax of the XPath query and ensure that operator precedence is observed.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 10/12/2001 |
---|
Keywords: | kbDSupport kbprb KB285163 |
---|
|