How to join values using XPath concat?

by scrapecrow Apr 19, 2023

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:

<html> <div> <h2>Coffee</h2> <span data-currency="USD">4.69</span> </div> </html>

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:

<html> <div> <h2>Coffee</h2> <span data-currency="USD">4.69</span> </div></html>

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.

Parsing HTML with Xpath

Related Articles

How to Parse XML

In this article, we'll explain about XML parsing. We'll start by defining XML files, their format and how to navigate them for data extraction.

PYTHON
CSS-SELECTORS
XPATH
DATA-PARSING
How to Parse XML

Ultimate XPath Cheatsheet for HTML Parsing in Web Scraping

Ultimate companion for HTML parsing using XPath selectors. This cheatsheet contains all syntax explanations with interactive examples.

XPATH
DATA-PARSING
Ultimate XPath Cheatsheet for HTML Parsing in Web Scraping

Web Scraping With Ruby

Introduction to web scraping with Ruby. How to handle http connections, parse html files for data, best practices, tips and an example project.

RUBY
HTTP
DATA-PARSING
CSS-SELECTORS
XPATH
INTRO
Web Scraping With Ruby

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.

DATA-PARSING
PARSEL
XPATH
PYTHON
Parsing HTML with Xpath

Web Scraping With PHP 101

Introduction to web scraping with PHP. How to handle http connections, parse html files for data, best practices, tips and an example project.

PHP
HTTP
DATA-PARSING
XPATH
INTRO
Web Scraping With PHP 101

Web Scraping With Scrapy: The Complete Guide in 2025

Tutorial on web scraping with scrapy and Python through a real world example project. Best practices, extension highlights and common challenges.

PYTHON
SCRAPY
FRAMEWORK
XPATH
INTRO
Web Scraping With Scrapy: The Complete Guide in 2025