تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
11585 أدوات العرض

Watching this sample code, how to xpath pointing to the second element called "example_a"?:

<span class="example_a"/>
<span class="example_b"/>
<span class="example_a"/>
الصورة الرمزية
إهمال
أفضل إجابة

Hi Roberto,

If you'd gave all classes an unique name you could do the following:

<xpath expr="//span[@class='example_a']>
    <!-- Some code here -->
</xpath>
But, since this is not the case, you should just use an index. For example:

<xpath expr="//span[3]">
    <!-- Some code here -->
</xpath>
This will search the third element that is a span. This code literally says 'get me the third item that is a span'.
Yenthe
الصورة الرمزية
إهمال
الكاتب

Thank you very much for your answer.

No problem, best of luck with Odoo!

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
أبريل 20
3706
1
أغسطس 19
6410
1
أكتوبر 16
6559
1
فبراير 25
2603
3
ديسمبر 24
2309