Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
#20: toString() moved to HTMLElement.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bystroushaak committed Nov 15, 2015
1 parent f92500c commit b864e79
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/dhtmlparser/htmlelement/html_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@ def __str__(self):
def __repr__(self):
return "HTMLElement(%s)" % repr(self.__str__())

def toString(self):
"""
Returns almost original string.
If you want prettified string, try :meth:`.prettify`.
Returns:
str: Complete representation of the element with childs, endtag \
and so on.
"""
output = ""

if self.childs or self.isOpeningTag():
output += self.tagToString()

for c in self.childs:
output += c.toString()

if self.endtag is not None:
output += self.endtag.tagToString()

elif not self.isEndTag():
output += self.tagToString()

return output

def getContent(self):
"""
Returns:
Expand Down

0 comments on commit b864e79

Please sign in to comment.