Created
September 26, 2011 16:49
-
-
Save netdesign/1242703 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i have same problem with you, so how did you fixed it ?