Search code examples
apixpathxquerytelegram

How to remove attribute of a tag in Telegram's instant view API?


I have this

<span class="img-fc">
  <img src="https://img1.ibxk.com.br/2017/04/12/12095959053024.png?w=700">
  <span class="desc">The image desc is here!</span>
</span>

So I used some functions of the API to change the description

<figure>: //span[@class="img-fc"]
<figcaption>: //figure[@class="img-fc"]/span[@class="desc"]

And I get this result in the instant view debug:

> @debug: $body//figure
Debug 1 node:
  [0]: <figure class="img-fc"><img src="https://img1.ibxk.com.br/2017/04/12/12095959053024.png?w=700"><figcaption class="desc">The image desc is here!</figcaption></figure>
Instant View successfully generated

But, its not generatig an img with a caption bellow the image. Here is the result: print


Solution

  • First step: convert all <span class="desc"> tag in <span class="img-fc"> tag to <figcaption> tag:

    <figcaption>: //span[has-class("img-fc")]//span[has-class("desc")]
    

    Second and final step is convert all <span class="img-fc"> tags to <figure>:

    <figure>: //span[has-class("img-fc")]