[xml] Python, node.name, scope
- From: Michael Rothwell <rothwell holly-springs nc us>
- To: xml gnome org
- Subject: [xml] Python, node.name, scope
- Date: Mon, 24 Feb 2003 15:04:42 -0500
In the code snippet below (infinite loop prevention and error checking
code removed), lines 3 and 4 work properly, and print the node name.
Line 6, however, yields the following error:
AttributeError: 'NoneType' object has no attribute 'name'
Is this a scope problem? A bug? What am I doing wrong? It seems to me
that line 6 should work if line 3 does.
1: doc = libxml2.recoverDoc(text)
2: node = doc.children
3: name = node.name
4: print "Node:" + name
5: while 1:
6: name = node.name
7: if node.name != 'text': break
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]