4
<iframe src="https://expmle.com/subdirectory/sample_title" />

How can I create and append below <a> tag from above code using XPath and Telegram Instant view functions?

<a href="https://expmle.com/subdirectory/sample_title">sample_title</a>

I want to extract whole src and last part of that and use of them to create <a> tag.

Any suggestions would be very appreciated :)

Alizadeh118
  • 974
  • 10
  • 17

2 Answers2

3

This should work correctly.

<a>: //iframe # Find iframe and convert it to <a>

@set_attr(href, ./@src) # Set href attribute from src

$anchor # Create variable for current <a>
@set_attr(text, ./@href) # We set new attribute for link which will processed by @match function, then @text attribute will be replaced by result of the @match
@match("\\w+_\\w+"): $@/@text # Now we find our future name of the link "sample_name" (this function will replace all in @text by our new name

@prepend(@text): $anchor # And then put this name to his $anchor
haacki47
  • 416
  • 1
  • 4
  • 15
1
# append <a> tag below
@after(<a>, href, ./@src, content, ./@src): //iframe

# take everything after the last slash
@match("[^\/]+$", "1"): $@/@content

# move the attribute inside the tag
@append(@content): $@

If the last $@ won't work, just define a variable for <a>.

xamgore
  • 1,723
  • 1
  • 15
  • 30