Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using ImportXML to pull URL and anchor of link containing the string

I'm trying to use ImportXML in Google Sheets to pull URL and anchor of link containing the string. Problem is that I want to avoid having string hardcoded and want it to be pulled from another cell.

Hardcoded example:

=IMPORTXML("http://www.debian.org/mirror/list", "//a/@href[contains(., 'about')]")

Desired outcome (using A2 instead of about):

=IMPORTXML("http://www.debian.org/mirror/list", "//a/@href[contains(., A2)]")

I tried putting A2 in quotes but that didn't work.

like image 932
dzhi Avatar asked Sep 08 '25 10:09

dzhi


1 Answers

Please try:

=IMPORTXML("http://www.debian.org/mirror/list", "//a/@href[contains(.,'"&A2&"' )]")  

ie single quotes (as before) around double quotes around &s.

like image 114
pnuts Avatar answered Sep 11 '25 03:09

pnuts