Xpaths - Specific Text Within Element?


Is it possible through custom scripts or creative XPath calls to retrieve specific text from an element instead of all the text contained within the element?

“//*/p” will return all the text (KINGMAN AZ 86401-3810)
and “//*p/strong” will return (86401-3810)

Is there a way to return only the root text in p and disregard the text in strong without having to use additional text actions?


Hello @wwylie.
Probably you can try with XPath axes like “preceding” and others.
XPath axes are described in our KB: https://kb.workfusion.com/display/RPAe/XPath+Guide#XPathGuide-XPathAxes
And also there are a couple of samples in XPath tutorial: https://www.tutorialspoint.com/xpath/xpath_quick_guide.htm

Let us know if this was helpful.
Thank you!

No, not really. I’d like to know if someone has an answer to my specific example. The issue is that xpaths in workfusion studio are set up to call on an element which returns the text value of that element; as opposed to calling on a specific section of text within the element. In my example, I need to call on the first line of text itself, not just the entire “p” element. Something like “//*p/text()[1]” will highlight the text I need when simply searching by xpath in the browser developer tools, but you can’t end an xpath with “text()” in workfusion studio.