Assuming my HTML is:
<html><body><span>This is my text</span></body></html>
How to get a string representation of what is contained inside, i.e.:
<span>This is my text</span>
To get an html view of an element, simply use the built-in function str:
str
soup = BeautifulSoup("<html><body><span>This is my text</span></body></html>") span = soup.find('span') str(span) # Outputs '<span>This is my text</span>'