I am trying to scrape permissions tables in the following site: https://register.fca.org.uk/ShPo_FirmDetailsPage?id=001b000000MfaDiAAJ
I am tryinng to find out if xpath is capable of locating a specific class with a text afterwards such as this (Please note ID are random so cannot locate using them, and also classes are the same for each table)
Advising on a home purchase plan
<div id="a2Nb000000035ohEAA" class="collapse DisciplineDetails PassportDetails PermDesc">
<h3 class="PermissionsListHeader">Advising on a home purchase plan</h3>
<br>
<br>
</div>
<ul class="PermissionConditionsList">
<li class="PermissionsConditionsItem">
Customer Type
<ul class="PermCondsLimitationsList">
<li style="list-style: none"><span id="j_id0:j_id1:j_id110:regActTable:0:j_id531:0:j_id533:0:j_id535:0:j_id538"></span></li>
<li class="PermCondsLimitationsItem Popover">Customer</li>
</ul>
</li>
</ul>
<ul class="PermissionConditionsList">
<li class="PermissionsConditionsItem">
Investment Type
<ul class="PermCondsLimitationsList">
<li style="list-style: none"><span id="j_id0:j_id1:j_id110:regActTable:0:j_id531:1:j_id533:0:j_id535:0:j_id538"></span></li>
<li class="PermCondsLimitationsItem Popover">Home purchase plans</li>
</ul>
</li>
</ul>
</div>
Still, it is hard to understand what you want to achieve.. As far as I understand, you need to parse PermCondsLimitationsItem Popover class value(s) (in this case Customer) based on whether the PermissionsListHeader class attribute value equals "Advising on a home purchase plan". If so, then save value of PermCondsLimitationsItem Popover class attribute.
So the following logic should do the thing.
Parse the < h3 > and test the initial condition:
//h3[@class='PermissionsListHeader']//text()
If the attribute value equals "Advising on a home purchase plan" parse PermCondsLimitationsItem Popover class.
//li[@class='PermCondsLimitationsItem Popover']//text()
If the condition is not satisfied, just put the blank space etc.