Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Use WEBSERVICE and FILTERXML in Excel for Windows

Fetch an XML response with WEBSERVICE, extract values with XPath, and troubleshoot format, platform, and refresh limitations using a small worked example.

Table of Contents

In supported desktop versions of Excel for Windows, WEBSERVICE retrieves a web response as text and FILTERXML extracts values from valid XML using XPath. This combination is useful for a small XML endpoint, but it is not a general website scraper or a scheduled live-data feed.

Check the platform and data format

Microsoft documents WEBSERVICE as relying on Windows features. FILTERXML is unavailable in Excel for Mac and Excel for the web.

Choose a documented endpoint that returns XML directly. JSON, an ordinary HTML page, a login screen, or a JavaScript-rendered page cannot simply be passed to FILTERXML. Check the provider’s access rules, request limits, and data-use terms.

1. Fetch the response with WEBSERVICE

How to use WEBSERVICE and FILTERXML functions to get data directly from the web and automatically update in Excel Picture 1
=WEBSERVICE(url)

Put the endpoint URL in A1, then enter this in B1:

=WEBSERVICE(A1)

Inspect B1 before writing extraction formulas. It should contain the expected XML, not an error page. A placeholder such as https://api.example.com/exchange-rates is only an example of a URL shape; it is not a working data service.

The function accepts a URL, with no argument for custom authentication headers. Use a supported connector or another appropriate data-access method when the service requires them. Avoid putting secrets into a shared workbook.

2. Test FILTERXML with a small example

How to use WEBSERVICE and FILTERXML functions to get data directly from the web and automatically update in Excel Picture 2
=FILTERXML(xml, xpath)

To learn the extraction step without depending on a live service, paste this illustrative XML into B1 as text:

<rates><currency name="USD">1</currency><currency name="EUR">0.9</currency></rates>

These are sample values, not exchange-rate information. In C1, enter:

=FILTERXML(B1,"//currency[@name='USD']")

The result is 1. The XPath selects a currency element whose name attribute is USD. Match capitalization and attribute names to the actual XML.

To request all currency elements, use:

=FILTERXML(B1,"//currency")

In a version supporting spilled arrays, leave the destination cells empty for multiple returned values. If you need one particular match, use a more specific XPath rather than assuming the first result is the one you want.

3. Combine the steps only after testing them

Once the fetch and XPath both work, you can combine them:

=FILTERXML(WEBSERVICE(A1),"//currency[@name='USD']")

Keeping the fetched XML in one cell is often easier to inspect when several formulas use the same response. Adapt the XPath to your provider’s structure; there is no universal path for every exchange-rate API.

Troubleshoot errors and refresh expectations

  • WEBSERVICE returns #VALUE!: check connectivity, the URL, response size, and whether the endpoint permits the request. Microsoft lists a 32,767-character response-cell limit and a 2,048-character URL limit.
  • FILTERXML returns #VALUE!: check that the response is valid XML. Undeclared or invalid namespace prefixes can also cause problems.
  • No expected value: inspect the actual tag names, hierarchy, attributes, and namespace handling instead of repeatedly changing the formula blindly.
  • Old data: these formulas do not define a timed refresh schedule. Confirm the source timestamp and your workbook’s calculation behavior; a successful calculation alone does not prove the data is current.

For JSON, larger datasets, repeatable transformations, or connection refresh controls, investigate Power Query. Our Excel feature overview introduces it, and the Power Query data-combination guide shows how saved transformation steps can support recurring work.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.