且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么XPath中的索引从1开始而不是0?

更新时间:2023-02-19 12:18:57

数组和其他集合索引表示内存偏移,因此逻辑上它们从零开始。 XML和XPATH索引代表位置和计数,因此逻辑上它们从一开始(零因此代表空)

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")