I am writing xpath for elements present under svg tag. I want to get the 2nd rect node.
My xpath finds all 3 nodes, whereas my requirement is to find only the 2nd -
xpath: //*[name()='svg']/*[name()='rect' and @fill='#919EF9']
HTML sample,
<svg width="400" height="110">
<rect id="yui_3_6_0_1_1435305312018_1190" x="35.5" y="60.5" width="68" height="117" stroke="#FFFFFF" stroke-width="1" fill="#919EF9" rx="0" ry="0">
<rect x="176.5" y="65.5" width="68" height="48" stroke="#FFFFFF" stroke-width="1" fill="#919EF9" rx="0" ry="0">
<rect x="316.5" y="30.5" width="68" height="70" stroke="#FFFFFF" stroke-width="1" fill="#919EF9" rx="0" ry="0">
</svg>
Use
[n]
to select thenth
element:use following XPATH