Why do indexes in XPath start with 1 and not 0?

Array and other collection indexes represent memory offsets, so logically enough they begin at zero. XML and XPATH indexes represent positions and counts, so logically enough they begin at one (and zero is therefore representative of “empty”)

Leave a Comment