Search code examples
xpathgoogle-sheetsrow

Exporting Table Data to Google Spreadsheet via XPath


I´m trying to export table data to Google Spreadsheet by using the importxml command and XPath but it doesn´t work. A parser error appears, which says that there´s an error while parsing the formula.

I want to get the mobile PIs from this page: http://ausweisung.ivw-online.de/index.php?i=1121&a=a9170

I tried a command like this: =IMPORTXML("http://ausweisung.ivw-online.de/index.php?i=1121&a=a9170"; "//*[@id="ibody"]//div[1]/div/div[3]/div[2]/table/tbody/tr[4]/td[5]")

As mentioned in the comments below, I also want to perform the request more dynamic. I want to search for a specific string and then jump to a column of my choice.


Solution

  • Thanks to a user from the Google product forums I got the right formula to solve my request correctly.

    =arrayformula( value( regexreplace( query( importHTML("http://ausweisung.ivw-online.de/index.php?i=112&mz_szm=201408"; "table"; 3) & ""; "select Col5 where Col3 = 'GLAMOUR (Smartphone-Apps)' "; 0 ); "[^\d]"; "" ) ) )

    This request is looking for a specific string in a specified table, and grabs the data from the fifth column in this row.