Extracting certain text from HTML table


#1

Hi,

I’m trying to get text after a certain word appears in a table to write back into an Excel spread sheet, but the word is in the next column and in a different row, which will change with each instance.

E.g. the selector I want for the certain word is:
<*webctrl tag=‘TABLE’ />
<*webctrl tableCol=‘2’ tableRow=‘7’ tag=‘TD’ />

and the word I want to find is in:
<*webctrl tag=‘TABLE’ />
<*webctrl isleaf=‘1’ tableCol=‘5’ tableRow=‘6’ tag=‘TD’ />

On another example, the selector for the certain word is:
<*webctrl tag=‘TABLE’ />
<*webctrl tableCol=‘2’ tableRow=‘23’ tag=‘TD’ />

and the word I want to find is:
<*webctrl tag=‘TABLE’ />
<*webctrl isleaf=‘1’ tableCol=‘5’ tableRow=‘22’ tag=‘TD’ />

(minus the *'s otherwise it wouldn’t show up)

So basically what I’m asking is, is there a way for there to be an anchor or something similar for a word, and for you to then get the text which will always be the same position away from it, for it to then write back to Excel?


#2

Hello @Short,

If I am correct, there is a pattern in both the words as follows-

  • TableCol is fixed for Word1 as 2 and Word2 as 5
  • TableRow for Word2 is 1 less than that of Word1 (i.e 7-1=6 Or 23-1=22)

You can try below method for the same.

  • Use Find Element Activity with selector having aaname property for Word1, <*webctrl aaname=‘Some Word’ tag=‘TD’/>, which will return a UIElement,

  • Get its selector by using uielem.Selector Property. Selector will have TableRow and TableCol for the particular cell

  • Get TableRow & TableCol Values by using SubString

  • Search Word2 with below manipulated selector,

<*webctrl tag=‘TABLE’ />
<*webctrl isleaf=‘1’ tableCol=‘5’ tableRow=’<tablerow_word1 - 1>’ tag=‘TD’ />

Regards
Madhura


#3

Hi @Madhuraj

Thanks for the reply :slight_smile: Unfortunately I still can’t get it to work. Is there a way you could come up with a sample to upload? Sorry to be a pain

Thank you


#4

Hello @Short ,

Can you upload a sample screen shot of your table so that we can get more idea about your issue.

:slight_smile:

Regards
Madhura


#5

Hi @Madhuraj

Of course, sorry!

I’ve posted two examples, both in a different colour. Each “tableCol” is a word that I’ve had to blank out (the ones on the left hand side are where the dates are) but I’ve put the column number on there for information. The tableRow at the side is for all of the ones on that row, and they all begin with "isleaf=“1"” but I didn’t have the room to add it on.

Hope this makes sense, please let me know if anything else is needed.

Thanks :slight_smile: