Hello.
I'm learning ElementSoup, but it doesn't work the way it's supposed to be.
I tried sample code in doc/elementsoup.txt but failed with error.
---------------------------------------------------------------------------------------------------------------------
>>> tag_soup = '<meta><head><title>Hello</head<body onload=crash()>Hi all<p>'
>>> from lxml.html.ElementSoup import parse
>>> from StringIO import StringIO
>>> root = parse(StringIO(tag_soup))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/lib/python2.5/site-packages/lxml-2.0alpha3-py2.5-macosx-10.3-i386.egg/lxml/html/ElementSoup.py",
line 19, in parse
root = _convert_tree(tree, makeelement)
File "/opt/local/lib/python2.5/site-packages/lxml-2.0alpha3-py2.5-macosx-10.3-i386.egg/lxml/html/ElementSoup.py",
line 40, in _convert_tree
attrib=dict(beautiful_soup_tree.attrs))
File "parser.pxi", line 702, in etree._BaseParser.makeelement
File "apihelpers.pxi", line 102, in etree._makeElement
File "apihelpers.pxi", line 798, in etree._tagValidOrRaise
ValueError: Invalid tag name u'[document]'
---------------------------------------------------------------------------------------------------------------------
I'm using
Python2.5
lxml-2.0alpha3
BeautifulSoup 3.0.4
Any clues?