Thursday, August 24, 2017

FILTERXML function

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.

1 comment:

  1. microsoft office 2016 professional plus (Retail License this specialised and efficient tool to enhance business productivity in a quick and easy way. Get your favourite applications to be downloaded absolutely free, which includes Word, Excel, Power-point, One-note, Outlook, Publisher and Access, Office 2010 Professional, streamlines all business needs from sales tracking, data analysis and budget-building to ad creation, business reports and customer newsletters with a single, high-performance Office suite.

    ReplyDelete