Xpath 1st elment 2nd element 3rd element
<h1 class="name">Ankit Pal</h1>
How can I write a XPath to get the first name as Ankit and last name as Pal in excel sheet
any other possible solutions are also welocmed which can help
-
2 step process
1. Define field xpath:
/descendant-or-self::h1[@class="name"]
2.Then add cleaning rules to match regex for the part of the name you want.
You can use the regex builder to define starting character and end character. So the first part of the name might be \w (for a word character) tick include starting character, and the end character enter a space.Should pick up Ankit
Repeat in second column for the other part of the name.
You can use the same rule, this time including the end character, but with a regex replace leaving the replace field blank and you should be left with the last part of the name.
Note: the regex builder adds an unnecessary \ to the built expression when using regex metacharacters. Just delete one of them.
For more help with regex expressions check out:
https://www.w3schools.com/jsref/jsref_obj_regexp.asp
Please sign in to leave a comment.
Comments
1 comment