Since when did XPath collections start at 1?
I just discovered that in MSXML 4 XPath you select the 1st of something using:
/books/book[1]
Wheras previous to this it was (and the MSXML 3 docs conform this too):
/books/book[0]
So how come there wasn't a huge furore about this? -- surely lots of things have broken/will break? But I look at http://www.w3.org/TR/xpath and find that indeed:
"para[1] selects the first para child of the context node"
I admit by looking at the w3.org docs I've been doing it wrong all these years... why didn't MS get their act together sooner? Or am I missing something? (I'm actually using System.Xml in .NET which exhibits the "correct" 1-based behaviour.)
Duncan Smart
Friday, October 10, 2003
Interesting... that's something I've never noted. Perhaps because I'm used to get collection of nodes, and never access it through absolute position indexes...
How strange.
Leonardo Herrera
Friday, October 10, 2003
Isn't it better to use position() = 0 to get the first element in a set?
Johnny Bravo
Friday, October 10, 2003
Well I guess I know what I will be doing monday... Checking all my XML code. Thanks for making me look forward to monday even more!
Does MSXML 4 still provide some sort of backwards compatible [0] index functionality? Because I assume this is likely to break a lot of stuff if people switch to it without checking first.
Chris
Saturday, October 11, 2003
Probably--that's why there MSXML2.DOMDocument2, DOMDocument3, etc. If you just switch DLLs and keep using the old CLSID/ProgID, nothing should break; if you switch which class you use, things could change.
mb
Saturday, October 11, 2003
Recent Topics
Fog Creek Home
|