Question: I'm using the "IMPORTXML" function on Google Spreadsheets to get the number of likes and comments on any given YouTube video. However, I can't find the right XPath, and all I've tried return an empty value.

I used ChroPath to extract the XPath of the comments and likes count, but to no success.

This is the XPath that I've been using for amount of comments:

```
//yt-formatted-string[@class='count-text style-scope ytd-comments-header-renderer']

```

And this is for amount of likes:

```
//div[@id='info']//ytd-toggle-button-renderer[1]//a[1]//yt-icon-button[1]

```

When I try those it just says the content is empty. What is the correct XPath that I should be using to get the number of likes and comments?

Answer: 
* You want to retrieve the number of likes of the video on YouTube.
* You want to put the value to the Spreadsheet.

How about this formula? Please think of this as just one of several answers.

### Sample formula:

```
=VALUE(IMPORTXML(A1,"//button[@title='I like this']/span"))

```

* In this case, the cell "A1" is the URL like `https://www.youtube.com/watch?v=###`.
* Xpath is `//button[@title='I like this']/span"`.

### Sample script of Google Apps Script:

As another method for retrieving the number of likes, if you use Advanced Google services of Google Apps Script, the sample script is as follows.

```
var count = YouTube.Videos.list("statistics", {id: "###"}).items[0].statistics.likeCount;

```

* `###` is the video's ID.

### References:

* [IMPORTXML](https://support.google.com/docs/answer/3093342)
* [VALUE](https://support.google.com/docs/answer/3094220)
* [Advanced Google services](https://developers.google.com/apps-script/guides/services/advanced)
* [Videos: list](https://developers.google.com/youtube/v3/docs/videos/list)

If I misunderstood your question and this was not the result you want, I apologize.
for YT likes you could use:

```
=IF(ISNA(IMPORTXML("https://www.youtube.com/watch?v=MkgR0SxmMKo","(//*[contains(@class,'like-button-renderer-like-button')])[1]"))=TRUE,0,
         IMPORTXML("https://www.youtube.com/watch?v=MkgR0SxmMKo","(//*[contains(@class,'like-button-renderer-like-button')])[1]"))

```