当前位置:网站首页>Position() function in XPath uses

Position() function in XPath uses

2022-07-06 07:37:00 Sub Archaean hyperevolution

Just want to get a few of the elements

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>welcome to my index</title>
</head>
<body>
    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
        <li>7</li>
        <li>8</li>
        <li>9</li>
    </ul>
</body>
</html>

How to get the third to sixth li label
//ul/li[position()>2][position()<5]
//position() Position in variable [2] Inside
Find time li The label is greater than two , Start with the third one , Then find four more li label
I have seen many people explain position() function , But I didn't say how this matched , My current understanding is like this .
Explain it. :
position()>2 It means to start from the third element
position()<5 It means take 4 Elements
So the combination of these two is to take the third and sixth labels

原网站

版权声明
本文为[Sub Archaean hyperevolution]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060733013330.html