Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

JV

By: a guest on Dec 19th, 2008  |  syntax: Python  |  size: 0.51 KB  |  views: 60  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. In [51]: from elementtree import ElementTree as et
  2.  
  3. In [52]: s
  4. Out[52]: '<p>blah <b>bleh</b> blih</p>'
  5.  
  6. In [53]: t=et.fromstring(s)
  7.  
  8. In [54]: " ".join( [ t.tostring() for t in t.findall('*') ] )
  9. ---------------------------------------------------------------------------
  10. <type 'exceptions.AttributeError'>        Traceback (most recent call last)
  11.  
  12. /home/jv/KnowledgeMate/KnowledgeMate/<ipython console> in <module>()
  13.  
  14. <type 'exceptions.AttributeError'>: _ElementInterface instance has no attribute 'tostring'