FILTERXML function

This article describes the formula syntax and usage of the FILTERXML function in Microsoft Excel.

Note   The FILTERXML function is not available in Excel Online, and it is not available in Excel 2016 for Mac.

Description

Returns specific data from the XML content by using the specified XPath.

Syntax

FILTERXML(xml, xpath)

The FILTERXML function syntax has the following arguments.

  • Xml    Required. A string in valid XML format.

  • Xpath   Required. A string in standard XPath format.

Remarks

  • If xml is not valid, FILTERXML returns the #VALUE! error value.

  • If xml contains a namespace with a prefix that is not valid, FILTERXML returns the #VALUE! error value.

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Query URL:

http://en.wikipedia.org/w/api.php?action=query&list=recentchanges&rcnamespace=0&format=xml

XML Response:

=WEBSERVICE(A2)

Most recently changed:

=FILTERXML(B3,"//rc/@title")

=FILTERXML(B3,"//rc/@timestamp")

=FILTERXML(B3,"//rc/@title")

=FILTERXML(B3,"//rc/@timestamp")

=FILTERXML(B3,"//rc/@title")

=FILTERXML(B3,"//rc/@timestamp")

Description

This example uses the FILTERXML function on XML data returned in cell B3, which is provided by the results of the WEBSERVICE function on the web query in cell A2. The data from FILTERXML is returned in cells B7:B9 and C7:C9, and shows the three most recently updated query results on Wikipedia and the time of their updates (in UTC, "Coordinated Universal Time").

Cells B7:B9 contain the formula =FILTERXML(B3,"//rc/@title"), which needs to be entered as an array formula in those cells. Select B7:C9, enter the formula, and press Ctrl+Shift+Enter. Cells C7:C9 contain the formula =FILTERXML(B3,"//rc/@timestamp"), and also needs to be entered as an array formula.

Applies To: Excel 2013, Excel Online



Was this information helpful?

Yes No

How can we improve it?

255 characters remaining

To protect your privacy, please do not include contact information in your feedback. Review our privacy policy.

Thank you for your feedback!

Support resources

Change language