Use Xpath to get all the rows of a table after a specific row in Automation Anywhere
I am trying to get the values of all the row after a specific row(This specific row can be identified using id) using xpath. Kindly note that i am using it in automation anywhere's object cloning command to locate and fetch the details.
lets say this is the table:
<table class="actiontable" >
<tbody>
<tr></tr>
<tr></tr>
<tr id="h32423">
<td class="claim"><span id="claimants">Claimants</span></td>
</tr>
<tr id="a23">
<td id="g543"><a href="some site">Edward Hunter</a> </td>
</tr>
<tr>
<td id="g544"><a href="some site">Jane Doe</a> </td>
</tr>
<tr></tr>
</tbody>
</table>
Here in the above table I need to fetch all the name after the Claimants row. Any suggestions?
xpath automationanywhere
add a comment |
I am trying to get the values of all the row after a specific row(This specific row can be identified using id) using xpath. Kindly note that i am using it in automation anywhere's object cloning command to locate and fetch the details.
lets say this is the table:
<table class="actiontable" >
<tbody>
<tr></tr>
<tr></tr>
<tr id="h32423">
<td class="claim"><span id="claimants">Claimants</span></td>
</tr>
<tr id="a23">
<td id="g543"><a href="some site">Edward Hunter</a> </td>
</tr>
<tr>
<td id="g544"><a href="some site">Jane Doe</a> </td>
</tr>
<tr></tr>
</tbody>
</table>
Here in the above table I need to fetch all the name after the Claimants row. Any suggestions?
xpath automationanywhere
1
Show what you've tried
– Andersson
Nov 15 '18 at 8:19
I used the below one but it brings every <tr> , but i want what is after claimants //table[@class="actionTable"]/descendant::tr
– g444ran
Nov 15 '18 at 9:25
Check answer i update your XPath
– Amrendra Kumar
Nov 15 '18 at 9:34
add a comment |
I am trying to get the values of all the row after a specific row(This specific row can be identified using id) using xpath. Kindly note that i am using it in automation anywhere's object cloning command to locate and fetch the details.
lets say this is the table:
<table class="actiontable" >
<tbody>
<tr></tr>
<tr></tr>
<tr id="h32423">
<td class="claim"><span id="claimants">Claimants</span></td>
</tr>
<tr id="a23">
<td id="g543"><a href="some site">Edward Hunter</a> </td>
</tr>
<tr>
<td id="g544"><a href="some site">Jane Doe</a> </td>
</tr>
<tr></tr>
</tbody>
</table>
Here in the above table I need to fetch all the name after the Claimants row. Any suggestions?
xpath automationanywhere
I am trying to get the values of all the row after a specific row(This specific row can be identified using id) using xpath. Kindly note that i am using it in automation anywhere's object cloning command to locate and fetch the details.
lets say this is the table:
<table class="actiontable" >
<tbody>
<tr></tr>
<tr></tr>
<tr id="h32423">
<td class="claim"><span id="claimants">Claimants</span></td>
</tr>
<tr id="a23">
<td id="g543"><a href="some site">Edward Hunter</a> </td>
</tr>
<tr>
<td id="g544"><a href="some site">Jane Doe</a> </td>
</tr>
<tr></tr>
</tbody>
</table>
Here in the above table I need to fetch all the name after the Claimants row. Any suggestions?
xpath automationanywhere
xpath automationanywhere
asked Nov 15 '18 at 7:36
g444rang444ran
11
11
1
Show what you've tried
– Andersson
Nov 15 '18 at 8:19
I used the below one but it brings every <tr> , but i want what is after claimants //table[@class="actionTable"]/descendant::tr
– g444ran
Nov 15 '18 at 9:25
Check answer i update your XPath
– Amrendra Kumar
Nov 15 '18 at 9:34
add a comment |
1
Show what you've tried
– Andersson
Nov 15 '18 at 8:19
I used the below one but it brings every <tr> , but i want what is after claimants //table[@class="actionTable"]/descendant::tr
– g444ran
Nov 15 '18 at 9:25
Check answer i update your XPath
– Amrendra Kumar
Nov 15 '18 at 9:34
1
1
Show what you've tried
– Andersson
Nov 15 '18 at 8:19
Show what you've tried
– Andersson
Nov 15 '18 at 8:19
I used the below one but it brings every <tr> , but i want what is after claimants //table[@class="actionTable"]/descendant::tr
– g444ran
Nov 15 '18 at 9:25
I used the below one but it brings every <tr> , but i want what is after claimants //table[@class="actionTable"]/descendant::tr
– g444ran
Nov 15 '18 at 9:25
Check answer i update your XPath
– Amrendra Kumar
Nov 15 '18 at 9:34
Check answer i update your XPath
– Amrendra Kumar
Nov 15 '18 at 9:34
add a comment |
3 Answers
3
active
oldest
votes
You need to check the preceding-sibling
data like this:
//tr[preceding-sibling::tr[normalize-space(.)='Claimants']]
You can try this as per your comment:
/table[@class='actiontable']/descendant::tr[normalize-space(lower-case(.))!= 'claimants']
add a comment |
For your simple example you can do the following in the Automation Anywhere editor:
Add a loop command with a Times
condition of 2
Inside the loop object clone one of the fields you want to access and change the DOMXPath
to
/html/body/table[1]/tbody[1]/tr[$Counter$+3]/td[1]/a[1]
Select Action
to be Get Property
and Select Property
to HTML InnerText
Assign this to a variable of your choice
Output this variable via a message box command
When run you should then see displayed the two names.
In this we are using the AA counter variable to iterate through the DOMXPath. I have adjusted it by 3 as there are 3 <tr>
tags before the row you wish to start on
The problem is it is not always 2. The number of rows after claimants varies dynamically. So I cannot iterate it 2 times, all the time.
– g444ran
Nov 15 '18 at 9:44
As mentioned this was for your simple example. You have a few strategies you can follow to get the count. a) Clone the table and get the total rows (you will need to adjust this to get the starting position b) change the loop to a condition and then wrap the object cloning in an error handler in which you set your condition. This means it will loop through all the rows until it doesn't work and then exit the loop
– Dohsan
Nov 15 '18 at 9:52
add a comment |
I'm not sure whether it's too late to answer or not. I think the following XPath match your condition.
//tr[td[span[@id='claimants']]]/following-sibling::tr/td/a
*You can change /tr/td/a
to /tr
or /tr/td
according to which element you want to access
I try this XPath in XPath Search console on Google Chrome and it navigate to all a
tags after the row which has ID = claimants.
As I'm quite new to AA, I don't know how to loop through those a tags getting from the XPath. But I hope this help you solve the problem. :)
[Update] I found the solution
1. Using //tr[td[span[@id='claimants']]]
with Object Cloning to get the index of the specific row. Let's say the index value is stored in variable $vIndex$
2. Loop through all td
in the table
3. If the $Counter$
> $vIndex$
THEN that is the row under the specific row.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53314467%2fuse-xpath-to-get-all-the-rows-of-a-table-after-a-specific-row-in-automation-anyw%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to check the preceding-sibling
data like this:
//tr[preceding-sibling::tr[normalize-space(.)='Claimants']]
You can try this as per your comment:
/table[@class='actiontable']/descendant::tr[normalize-space(lower-case(.))!= 'claimants']
add a comment |
You need to check the preceding-sibling
data like this:
//tr[preceding-sibling::tr[normalize-space(.)='Claimants']]
You can try this as per your comment:
/table[@class='actiontable']/descendant::tr[normalize-space(lower-case(.))!= 'claimants']
add a comment |
You need to check the preceding-sibling
data like this:
//tr[preceding-sibling::tr[normalize-space(.)='Claimants']]
You can try this as per your comment:
/table[@class='actiontable']/descendant::tr[normalize-space(lower-case(.))!= 'claimants']
You need to check the preceding-sibling
data like this:
//tr[preceding-sibling::tr[normalize-space(.)='Claimants']]
You can try this as per your comment:
/table[@class='actiontable']/descendant::tr[normalize-space(lower-case(.))!= 'claimants']
edited Nov 15 '18 at 9:33
answered Nov 15 '18 at 9:18
Amrendra KumarAmrendra Kumar
1,1291311
1,1291311
add a comment |
add a comment |
For your simple example you can do the following in the Automation Anywhere editor:
Add a loop command with a Times
condition of 2
Inside the loop object clone one of the fields you want to access and change the DOMXPath
to
/html/body/table[1]/tbody[1]/tr[$Counter$+3]/td[1]/a[1]
Select Action
to be Get Property
and Select Property
to HTML InnerText
Assign this to a variable of your choice
Output this variable via a message box command
When run you should then see displayed the two names.
In this we are using the AA counter variable to iterate through the DOMXPath. I have adjusted it by 3 as there are 3 <tr>
tags before the row you wish to start on
The problem is it is not always 2. The number of rows after claimants varies dynamically. So I cannot iterate it 2 times, all the time.
– g444ran
Nov 15 '18 at 9:44
As mentioned this was for your simple example. You have a few strategies you can follow to get the count. a) Clone the table and get the total rows (you will need to adjust this to get the starting position b) change the loop to a condition and then wrap the object cloning in an error handler in which you set your condition. This means it will loop through all the rows until it doesn't work and then exit the loop
– Dohsan
Nov 15 '18 at 9:52
add a comment |
For your simple example you can do the following in the Automation Anywhere editor:
Add a loop command with a Times
condition of 2
Inside the loop object clone one of the fields you want to access and change the DOMXPath
to
/html/body/table[1]/tbody[1]/tr[$Counter$+3]/td[1]/a[1]
Select Action
to be Get Property
and Select Property
to HTML InnerText
Assign this to a variable of your choice
Output this variable via a message box command
When run you should then see displayed the two names.
In this we are using the AA counter variable to iterate through the DOMXPath. I have adjusted it by 3 as there are 3 <tr>
tags before the row you wish to start on
The problem is it is not always 2. The number of rows after claimants varies dynamically. So I cannot iterate it 2 times, all the time.
– g444ran
Nov 15 '18 at 9:44
As mentioned this was for your simple example. You have a few strategies you can follow to get the count. a) Clone the table and get the total rows (you will need to adjust this to get the starting position b) change the loop to a condition and then wrap the object cloning in an error handler in which you set your condition. This means it will loop through all the rows until it doesn't work and then exit the loop
– Dohsan
Nov 15 '18 at 9:52
add a comment |
For your simple example you can do the following in the Automation Anywhere editor:
Add a loop command with a Times
condition of 2
Inside the loop object clone one of the fields you want to access and change the DOMXPath
to
/html/body/table[1]/tbody[1]/tr[$Counter$+3]/td[1]/a[1]
Select Action
to be Get Property
and Select Property
to HTML InnerText
Assign this to a variable of your choice
Output this variable via a message box command
When run you should then see displayed the two names.
In this we are using the AA counter variable to iterate through the DOMXPath. I have adjusted it by 3 as there are 3 <tr>
tags before the row you wish to start on
For your simple example you can do the following in the Automation Anywhere editor:
Add a loop command with a Times
condition of 2
Inside the loop object clone one of the fields you want to access and change the DOMXPath
to
/html/body/table[1]/tbody[1]/tr[$Counter$+3]/td[1]/a[1]
Select Action
to be Get Property
and Select Property
to HTML InnerText
Assign this to a variable of your choice
Output this variable via a message box command
When run you should then see displayed the two names.
In this we are using the AA counter variable to iterate through the DOMXPath. I have adjusted it by 3 as there are 3 <tr>
tags before the row you wish to start on
answered Nov 15 '18 at 9:36
DohsanDohsan
2768
2768
The problem is it is not always 2. The number of rows after claimants varies dynamically. So I cannot iterate it 2 times, all the time.
– g444ran
Nov 15 '18 at 9:44
As mentioned this was for your simple example. You have a few strategies you can follow to get the count. a) Clone the table and get the total rows (you will need to adjust this to get the starting position b) change the loop to a condition and then wrap the object cloning in an error handler in which you set your condition. This means it will loop through all the rows until it doesn't work and then exit the loop
– Dohsan
Nov 15 '18 at 9:52
add a comment |
The problem is it is not always 2. The number of rows after claimants varies dynamically. So I cannot iterate it 2 times, all the time.
– g444ran
Nov 15 '18 at 9:44
As mentioned this was for your simple example. You have a few strategies you can follow to get the count. a) Clone the table and get the total rows (you will need to adjust this to get the starting position b) change the loop to a condition and then wrap the object cloning in an error handler in which you set your condition. This means it will loop through all the rows until it doesn't work and then exit the loop
– Dohsan
Nov 15 '18 at 9:52
The problem is it is not always 2. The number of rows after claimants varies dynamically. So I cannot iterate it 2 times, all the time.
– g444ran
Nov 15 '18 at 9:44
The problem is it is not always 2. The number of rows after claimants varies dynamically. So I cannot iterate it 2 times, all the time.
– g444ran
Nov 15 '18 at 9:44
As mentioned this was for your simple example. You have a few strategies you can follow to get the count. a) Clone the table and get the total rows (you will need to adjust this to get the starting position b) change the loop to a condition and then wrap the object cloning in an error handler in which you set your condition. This means it will loop through all the rows until it doesn't work and then exit the loop
– Dohsan
Nov 15 '18 at 9:52
As mentioned this was for your simple example. You have a few strategies you can follow to get the count. a) Clone the table and get the total rows (you will need to adjust this to get the starting position b) change the loop to a condition and then wrap the object cloning in an error handler in which you set your condition. This means it will loop through all the rows until it doesn't work and then exit the loop
– Dohsan
Nov 15 '18 at 9:52
add a comment |
I'm not sure whether it's too late to answer or not. I think the following XPath match your condition.
//tr[td[span[@id='claimants']]]/following-sibling::tr/td/a
*You can change /tr/td/a
to /tr
or /tr/td
according to which element you want to access
I try this XPath in XPath Search console on Google Chrome and it navigate to all a
tags after the row which has ID = claimants.
As I'm quite new to AA, I don't know how to loop through those a tags getting from the XPath. But I hope this help you solve the problem. :)
[Update] I found the solution
1. Using //tr[td[span[@id='claimants']]]
with Object Cloning to get the index of the specific row. Let's say the index value is stored in variable $vIndex$
2. Loop through all td
in the table
3. If the $Counter$
> $vIndex$
THEN that is the row under the specific row.
add a comment |
I'm not sure whether it's too late to answer or not. I think the following XPath match your condition.
//tr[td[span[@id='claimants']]]/following-sibling::tr/td/a
*You can change /tr/td/a
to /tr
or /tr/td
according to which element you want to access
I try this XPath in XPath Search console on Google Chrome and it navigate to all a
tags after the row which has ID = claimants.
As I'm quite new to AA, I don't know how to loop through those a tags getting from the XPath. But I hope this help you solve the problem. :)
[Update] I found the solution
1. Using //tr[td[span[@id='claimants']]]
with Object Cloning to get the index of the specific row. Let's say the index value is stored in variable $vIndex$
2. Loop through all td
in the table
3. If the $Counter$
> $vIndex$
THEN that is the row under the specific row.
add a comment |
I'm not sure whether it's too late to answer or not. I think the following XPath match your condition.
//tr[td[span[@id='claimants']]]/following-sibling::tr/td/a
*You can change /tr/td/a
to /tr
or /tr/td
according to which element you want to access
I try this XPath in XPath Search console on Google Chrome and it navigate to all a
tags after the row which has ID = claimants.
As I'm quite new to AA, I don't know how to loop through those a tags getting from the XPath. But I hope this help you solve the problem. :)
[Update] I found the solution
1. Using //tr[td[span[@id='claimants']]]
with Object Cloning to get the index of the specific row. Let's say the index value is stored in variable $vIndex$
2. Loop through all td
in the table
3. If the $Counter$
> $vIndex$
THEN that is the row under the specific row.
I'm not sure whether it's too late to answer or not. I think the following XPath match your condition.
//tr[td[span[@id='claimants']]]/following-sibling::tr/td/a
*You can change /tr/td/a
to /tr
or /tr/td
according to which element you want to access
I try this XPath in XPath Search console on Google Chrome and it navigate to all a
tags after the row which has ID = claimants.
As I'm quite new to AA, I don't know how to loop through those a tags getting from the XPath. But I hope this help you solve the problem. :)
[Update] I found the solution
1. Using //tr[td[span[@id='claimants']]]
with Object Cloning to get the index of the specific row. Let's say the index value is stored in variable $vIndex$
2. Loop through all td
in the table
3. If the $Counter$
> $vIndex$
THEN that is the row under the specific row.
edited Jan 10 at 9:45
answered Jan 10 at 8:11
Pandarian LdPandarian Ld
1621519
1621519
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53314467%2fuse-xpath-to-get-all-the-rows-of-a-table-after-a-specific-row-in-automation-anyw%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Show what you've tried
– Andersson
Nov 15 '18 at 8:19
I used the below one but it brings every <tr> , but i want what is after claimants //table[@class="actionTable"]/descendant::tr
– g444ran
Nov 15 '18 at 9:25
Check answer i update your XPath
– Amrendra Kumar
Nov 15 '18 at 9:34