Module etree syntax error
Would someone please explain the following syntax error that appears when importing the etree module: Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information.
from lxml import etree parser = etree.XMLParser() tree = etree.XML("<root></b>", parser)
Traceback (most recent call last):
File "
On 8/29/2011 10:56, Michael McLoughlin wrote:
Would someone please explain the following syntax error that appears when importing the etree module:
tree = etree.XML("<root></b>", parser)
"<root></b>" is invalid XML. Tags must be balanced, so you have to have either matched opening & closing tags, or a standalone tag (<b/>). You also don't need to manually instantiate a parser, unless you're setting some non-default options. Something similar would be:
from lxml import etree tree = etree.XML("<root><b/></root>")
I'd recommend reading up on the basics of XML, something like http://www.w3schools.com/xml/default.asp Jason
participants (3)
-
Jason Viers
-
Michael McLoughlin
-
Sérgio Basto