1

Possible Duplicate:
Equivalent to InnerHTML when using lxml.html to parse HTML

What is the equivalent of innerHTLML for cssselect using lxml.html with python 2.7?

import lxml.html, cssselect

doc = lxml.html.document_fromstring(htmldocstring)
e = doc.cssselect('div.mainl')[0]
print e.innerHTML #This doesn't work

How do I get the inner/outer html of e?

Outer html To get the outer html you do:

print lxml.html.tostring(e)

Still don't know how to get innerHTML.

Community
  • 1
  • 1
Eugene
  • 10,957
  • 20
  • 69
  • 97
  • It's not necessary to edit your answer with the duplicate link once you have already voted to close your question. That said I've gone ahead and closed it for you. You can still accept your own answer when time permits. – BoltClock Jan 25 '13 at 02:59

1 Answers1

3

Figured it out...

print lxml.html.tostring(e)
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Eugene
  • 10,957
  • 20
  • 69
  • 97