The concat()
function is an XPath expression is a string join function for multiple string values. It's useful when parsing an HTML document for a specific string through distributed multiple elements or attributes:
For example, let's see the below interactive XPath expression evaluation:
Above, we contact the name and price elements into a single string. However, we can join any number of elements. Here's an example through two or more arguments:
Note that concat()
only works with strings so it'll automatically try convert elements to their text()
values. For further details on XPath selectors, including common tips and tricks, refer to our dedicated guide.
Parsing HTML with Xpath
Introduction to xpath in the context of web-scraping. How to extract data from HTML documents using xpath, best practices and available tools.