Selector for dynamic table extraction

Hello,
I need to extract an HTML structured table from a website where the nr of columns changes. Can someone please help me:

  1. Figure out how to identify the nr of columns present in the table
  2. Configure the Extract Table Data settings with dynamic selector

Here is the current selector in the Table Settings property when there are 3 columns:

true false false true false false true false false true false false true false false

Sample of table:

Hi @devver,

To handle tables with a variable number of columns in UiPath, here’s a straightforward approach:

Determine the Number of Columns Dynamically:

  • Use the Find Children activity to get all <th> or <td> elements within the table’s header row. This will give you the exact number of columns. Just set the Find Children activity to target the header row (using the right selector for <tr>), and count the resulting elements to identify how many columns are in the table.
    Set Up the Extract Table Data Activity with a Flexible Selector:
  • In the Extract Table Data wizard, make sure to set up the selector to be flexible. Replace any static attributes related to column count with wildcards (*). For instance, use a dynamic setup for tableRow and tableCol attributes, which will let the extraction adjust automatically based on the table’s structure.
    Sample Dynamic Selector:
  • Here’s an example of a dynamic selector structure that should work regardless of column count:
<webctrl tag='TABLE' />
<webctrl tag='TR' tableRow='*' />
<webctrl tag='TD' tableCol='*' />

Fine-Tuning Extraction:

  • Once the selector is set up, use the Extract Table Data wizard to refine the extraction as needed. If it’s struggling to capture data correctly, try pairing it with the Anchor Base activity for more accuracy—especially if there are any static elements nearby that you can anchor to.

Cheers,
Kardelen

1 Like

@devver

Welcome to the community

Please show the seector properly…either a screenshot or use </> in options menu in forum while typing to make it visible…(for selector)

Also what do you mean by nr? Are the columns dynamic or the table selector?

Cheers

hi, I’ve managed to identify the number (nr) of columns. I still need help to make my selector dynamic pls cos the column numbers change everytime.

Here is from the Strict Selector:

<html app='chrome.exe' title='Table.html'/>
<webctrl css-selector='body&gt;div&gt;div&gt;div&gt;table' tag='TABLE' />

Thank you!
It works - I updated the Strict Selector to be dynamic per below, and targets my specific table by including the innnertext attribute.

<webctrl css-selector='table' tag='TABLE' innertext='     Name*' />

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.