Reputation: 792
I have markup as:
<p>Sample text. Click <a href="google.com">Here</a></p>
I want to replace the <p>
tag with <span>
without changing the children or text of the tag
Upvotes: 1
Views: 80
Reputation: 23451
Your task can be done using replaceWith
. You have to duplicate the element you want to use as the replacement, and then feed that as the argument to replaceWith
. The documentation for replaceWith
is pretty clear on how to do this.
In any case you could read this question How to change tag name with BeautifulSoup?
Upvotes: 1