3
我有以下代碼:如何使用Xpath定位此元素?
<g xmlns="http://www.w3.org/2000/svg" id="MainMenu1" display="block" transform="translate(1125, 0)">
<g dp:id="Content" xmlns:dp="http://dreampark.se/extensions" width="375" height="624" id="MainMenuViewMainMenu_DynamicChild3Content" _shadowId="MainMenuViewMainMenu_DynamicChild3Content">
<g transform="translate(0,0)" x="0" y="0" clip-path="url(#clipPath59)">
<g display="block" transform=" translate(0,208)">
<g id="RootMenuItem" width="376" height="50" display="block" buffered-rendering="static" transform="translate(0,0)">
<g id="RootMenuItemIconHolder" transform="translate(25,2)" display="none">
<image id="RootMenuItemIcon" opacity="1.0" width="40" height="40" display="block"/>
</g>
<foreignObject width="260" height="30" x="65" y="10" transform="null">
<body xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-size:22;color:#AAACAE" id="RootMenuItemText" original_x="null" fill="#AAACAE" font-size="22" width="298">Text 2</div>
</body>
</foreignObject>
</g>
<g id="RootMenuItem" width="376" height="50" display="block" buffered-rendering="static" transform="translate(0,52)">
<g id="RootMenuItemIconHolder" transform="translate(25,2)" display="block">
<image id="RootMenuItemIcon" opacity="1.0" width="40" height="40" display="block"/>
</g>
<foreignObject width="260" height="30" x="65" y="10" transform="null">
<body xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml" style="font-size:22;color:#AAACAE" id="RootMenuItemText" original_x="null" fill="#1D212D" font-size="22" width="298">Text 1</div>
</body>
</foreignObject>
</g>
</g>
</g>
</g>
</g>
我想找到與id="RootMenuItemText"
的元素,但我需要這一個元素爲元素的子誰是下一個元素的兄弟(這id
是"RootMenuItem"
),有具有id="RootMenuItemIconHolder"
的子女,"display"
屬性中的值爲"block"
。
我需要找到的元素是:
<div xmlns="http://www.w3.org/1999/xhtml" style="font-size:22;color:#AAACAE" id="RootMenuItemText" original_x="null" fill="#1D212D" font-size="22" width="298">Text 1</div>
我已經試過此XPath:
//*[@id="RootMenuItemIconHolder"][@display='block']/following-sibling::*[last()]
但它不是定位的元素。有誰知道哪個Xpath表達式可以幫助我找到元素?提前致謝。