2

Using IMPORTXML in google sheets. I want to extract part of the result into one cell.

=IMPORTXML(B1,"//div[@class='orca-rating SwtJyda color-yellow tbody-6']/span")

I got the result spread over several columns. B8:F8 result spread to B8:F8

The inspect element is like this. I only want the value "2". It is in cell B8. inspect element

I think this can be done using substring-after. But I could not get the correct result.

1
  • 1
    Although I'm not sure whether this is included in your expected direction, I proposed an answer. Could you please confirm it? If I misunderstood your question and that was not useful, I apologize. Commented Jan 3, 2023 at 8:33

2 Answers 2

3

In your situation, how about the following samples?

=REGEXREPLACE(JOIN("",IMPORTXML(B1,"//div[@class='orca-rating SwtJyda color-yellow tbody-6']/span")),"[^0-9]","")
=REGEXEXTRACT(JOIN("",IMPORTXML(B1,"//div[@class='orca-rating SwtJyda color-yellow tbody-6']/span")),"\((.*)\)")

References:

Sign up to request clarification or add additional context in comments.

Comments

1

I use this formula. That works too.

=INDEX(  IMPORTXML(B1,"//div[@class='orca-rating SwtJyda color-yellow tbody-6']/span"),3)

But tanaike's formula is very good.

1 Comment

thanks for the INDEX example. I could retrieve all values instead of just the 1st one adapted like so: =INDEX(REGEXREPLACE(IMPORTXML("https://www.forexfactory.com/calendar?month=jul.2023","//td[@class='calendar__cell calendar__impact impact calendar__impact calendar__impact--low']//span/@title"),"Impact Expected",""))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.