Navigate through html dom

Hi everybody

I want to navigate through the DOM of a webpage, with a specific structure. Actually, I don’t have clue how to solve this task safe, easy and reliable. Maybe somebody of you can give me an hint.

Given is a html structure like this:

<div id="[random_id]">
    <div id="field_01">...</div>
    <div id="" class="field_error">specific error for field 1</div>
    <div id="field_02">...</div>
    <div id="" class="field_error">different error for field 2</div>
    <div id="field_03">...</div>
  • fields have an uniqe id
  • error messages never have an id
  • field errors will always be shown below the corresponding field
  • field errors do only appear if an error exists. Here, field_03 does not have an error
  • fields and messages are not grouped in parent->child relationships
  • between those pairs can be various html tags. […] I simplified this example

Task is to get all the error messages and the exact corresponding field_id. It looks quite easy to get all the information. Actually, I used the find-children-activity to get all the error messages. That works fine. But I cannot get the corresponding field id.

Do you have an idea?


Such retrieval can be Server with the Bildung Blocks of UiPath e.g Data scrapping.
As an alternate the next Helping Activity is find children with a Filter to the Error divs.

For the id retrieval a Check in get Attribute in the HTML element ist suggested

Another Type of Control can be achieved with parsing the HTML snippet as XML and implementing the retrieval with the Provided APIs.

Can Share some more Details in your scenario e.g which Website/App does give the Input. What isbthe Main target of your Process?

Maybe my statements weren’t clear enough.
However, I found a way to get the data properly.

  1. Extract all div, which directly follows the root (use find_children)
  2. Iterate this collection to find each error message (for each)
  3. Use the index of each match minus 1 to get the corresponding field
  4. Use item.Get(“id”) to get the unique field_id

This looks somehow like a workaround but it works. There is maybe a smarter solution.