What is IMPORTXML in Google Sheets?
IMPORTXML fetches a URL and returns data matching an XPath query. You can scrape page titles, meta tags, table cells, or RSS-style XML fields. It is more precise than IMPORTHTML when you need one value or a repeating node set from structured markup.
When to use it
Use IMPORTXML for competitor price checks, SEO title monitoring, RSS fields, or any public page where XPath can target stable elements.
When to skip it
Skip IMPORTXML when the site needs a login, loads data only via API tokens, or changes CSS classes every week. A dedicated API integration is more reliable.
How it works
-
1
Open the page source or inspector and identify a stable XPath to the value you need.
-
2
Write =IMPORTXML(url, "//h1") or a more specific path such as //span[@class="price"].
-
3
Use array-friendly XPath when you need every matching node in a column of results.
-
4
Combine with IFERROR to show a friendly message when the fetch fails.
-
5
Cache important snapshots on a Schedule tab if you only need daily history, not live ticks.
-
6
Re-test XPath after site redesigns because class-based paths break often.
Examples in Google Sheets
Page title monitor
=IMPORTXML(landing_url, "//title") tracks homepage title text for SEO experiments.
Product price node
=IMPORTXML(product_url, "//span[@itemprop='price']") reads a published price when the schema markup is consistent.
RSS item titles
=IMPORTXML(feed_url, "//item/title") lists headlines from a public XML feed into a news tab.
Better Sheets resources
Common mistakes
-
Using brittle class names that minify or change on every deploy.
-
Expecting IMPORTXML to execute JavaScript-rendered prices on modern SPAs.
-
Pulling thousands of URLs with separate IMPORTXML formulas, hitting Google fetch limits.
-
Forgetting to escape quotes inside XPath strings in the formula bar.
-
Treating scraped values as numbers without VALUE or REGEXREPLACE cleanup.
Frequently asked questions
- IMPORTXML vs IMPORTHTML?
- IMPORTXML uses XPath for flexible node selection. IMPORTHTML imports whole indexed tables or lists.
- Why is IMPORTXML blank?
- Wrong XPath, private URL, blocked bot access, or markup that exists only after JavaScript runs.
- Can IMPORTXML return multiple rows?
- Yes when your XPath matches many nodes. Results spill down the column.
- Does IMPORTXML work with APIs?
- It works on XML or HTML URLs. JSON APIs need UrlFetchApp or IMPORTDATA for CSV endpoints.
- How do I debug XPath?
- Test the path in browser dev tools or an online XPath tester against the live HTML source.
- IMPORTXML refresh rate?
- Google throttles fetches. Treat it as periodic, not real-time.
- Can I combine two XPaths?
- Use separate formulas or concatenate results with TEXTJOIN after import.
Related Tutorials
Watch how IMPORTXML works
Zunaid Asks: How to get Get Meta from URLS? Answer: Use ImportXML()
Related terms
IMPORTHTML
IMPORTHTML fetches a public web page and returns a table or list from its HTML. You provide the URL, the query type (table or list), and the index of which table or list on the page to import. It is a quick scraper for simple pages without writing Apps Script.
Read guide →IMPORTRANGE
IMPORTRANGE loads values from a range in another Google spreadsheet into your current file. You pass the spreadsheet URL or key plus a range string with an optional sheet name. After you grant access once, the link stays live and updates when the source changes.
Read guide →IMPORTDATA
IMPORTDATA retrieves a text file from a web address and parses it into sheet cells. It works with comma- or tab-separated values published at a stable URL. Government open data, published exports, and simple report endpoints are common sources.
Read guide →GOOGLEFINANCE
GOOGLEFINANCE connects your sheet to Google market data. Pass a ticker symbol, an attribute like price or volume, and optional date range arguments for historical quotes. Portfolio trackers and FX dashboards use it to avoid manual price copy-paste.
Read guide →Done reading about IMPORTXML?
Membership unlocks 600+ tutorials, unlimited generators, and every template. Practical lessons. Zero fluff.
Need this once
Jump to a free tool or a single tutorial for this topic.
Learning Sheets for real
Unlock the full library, generators, and templates with membership.