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. 1

    Open the page source or inspector and identify a stable XPath to the value you need.

  2. 2

    Write =IMPORTXML(url, "//h1") or a more specific path such as //span[@class="price"].

  3. 3

    Use array-friendly XPath when you need every matching node in a column of results.

  4. 4

    Combine with IFERROR to show a friendly message when the fetch fails.

  5. 5

    Cache important snapshots on a Schedule tab if you only need daily history, not live ticks.

  6. 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.

Build this without starting from a blank cell

Use a Better Sheets tool for IMPORTXML, then watch a walkthrough when you want the full pattern.

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

Browse more tutorials
Zunaid Asks: How to get Get Meta from URLS? Answer: Use ImportXML()

Zunaid Asks: How to get Get Meta from URLS? Answer: Use ImportXML()

how would I do the following? In Google Sheets, it's in column A I have ...

Related glossary terms

Done reading about IMPORTXML?

Membership unlocks 636+ 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.