The Excel FILTERXML function pulls values out of an XML string using XPath — usually the response from WEBSERVICE. In Excel 365 a matching set spills, turning an API response into a column of values with one formula.
Syntax
| Argument | Description | |
|---|---|---|
xml | Required | A string of valid XML (often a WEBSERVICE result). |
xpath | Required | XPath query as text, e.g. "//item/price" for every price inside an item. |
How to use it
The classic pipeline — call an API, then mine the response:
And the famous pre-TEXTSPLIT trick: turn a delimited string into XML, then split it with XPath:
Windows desktop only: the Web functions (ENCODEURL, FILTERXML, WEBSERVICE) are not available in Excel for the Web, Excel for Mac, or mobile — cells show #NAME? there. For cross-platform data pulls, use Power Query (Data → From Web) instead.
Try it: interactive demo
Pick an XPath query and see what it extracts from a sample product XML.
Errors & common pitfalls
#VALUE! — invalid XML or XPath. The xml argument must be well-formed (every tag closed, one root element); HTML from a web page usually is NOT valid XML and fails. JSON fails too — FILTERXML speaks only XML.
Pitfall: expecting JSON support. Most modern APIs return JSON. FILTERXML can’t parse it — request an XML endpoint if one exists, or use Power Query, which parses JSON natively.
Windows desktop only: the Web functions (ENCODEURL, FILTERXML, WEBSERVICE) are not available in Excel for the Web, Excel for Mac, or mobile — cells show #NAME? there. For cross-platform data pulls, use Power Query (Data → From Web) instead.
Power Query is usually the better tool. These functions predate Power Query; for refreshable, authenticated, multi-row web data, Data → Get Data → From Web wins on every axis. The Web functions remain handy for quick one-cell lookups.
Practice workbook
Frequently asked questions
Can FILTERXML parse JSON?
How much XPath does it support?
Why does my result show only the first match?
Is the SUBSTITUTE-to-XML splitting trick still useful?
Master functions like this in one day
This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class