Reputation: 151
I am trying to create xpath so that it only returns order number instead of whole line.Please see attached screenshot
Upvotes: 2
Views: 3934
Reputation: 1106
You could also just use your normal Xpath selector to get the complete text, being "Your oder # is: 123456" and then perform a regex on the string like mentioned in Get numbers from string with regex
Upvotes: 1
Reputation: 526
What you want is the substring-after() function -
fn:substring-after(string1,string2)
Returns the remainder of string1 after string2 occurs in it
Example:
substring-after('12/10','/')
Result: '10'
For your situation -
substring-after(string(//p[contains(text(), "Your order # is")]), ": ")
To test this, I modified the DOM on this page to include a "Order Number: ####" string.
Upvotes: 2