Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can retrieve the headings for a table in IMPORTXML on Google Sheets by using the XPath function //table//th in combination with the importxml function. This XPath expression selects all the th elements within the table element.

Here's an example formula that retrieves the headings for the first table on a webpage:

=IMPORTXML("https://www.example.com/", "//table[1]//th")

This formula imports the headings for the first table on the webpage "https://www.example.com/". You can modify it to select a different table by changing the index within the XPath expression [1] to the index of the table you want to select.