Skip to content

Instantly share code, notes, and snippets.

@netdesign
Created September 26, 2011 16:49
Show Gist options
  • Select an option

  • Save netdesign/1242703 to your computer and use it in GitHub Desktop.

Select an option

Save netdesign/1242703 to your computer and use it in GitHub Desktop.
import lxml.etree as jq
string = "<p><b>HTTP header fields</b> are components of the message header of requests and responses in the <a href=\"/wiki/Hypertext_Transfer_Protocol\" title=\"Hypertext Transfer Protocol\">Hypertext Transfer Protocol</a> (HTTP). They define the operating parameters of an HTTP transaction.</p>"
html = jq.fromstring(string)
for par in html.xpath("//p"):
print par.text_content()
Traceback (most recent call last):
File "testNested.py", line 8, in <module>
print par.text_content()
AttributeError: 'lxml.etree._Element' object has no attribute 'text_content'
@vose2008

Copy link
Copy Markdown

i have same problem with you, so how did you fixed it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment