Hi!
Something makes me crazy!!!
I wanna read some XML, but everytime I got "None" for the value of prop:
The code is:
from xml.dom import minidom
import sys
ResultList = []
def LoadProps(PropTag):
print PropTag
t_forms = PropTag.getElementsByTagName('form')
for t_form in t_forms:
t_comps = t_form.getElementsByTagName('component')
for t_comp in t_comps:
t_props = t_comp.getElementsByTagName('prop')
for t_prop in t_props:
attrs = t_prop.attributes.keys()
print attrs
print t_prop.nodeName
print t_prop.nodeType
print [t_prop.nodeValue]
sys.exit()
doc = minidom.parse('c:\\teszt3.xml')
print doc
t_langfile = doc.documentElement
t_props = doc.getElementsByTagName('properties')[0]
t_constants = doc.getElementsByTagName('constants')[0]
LoadProps(t_props)
-------------------
The result is:
>>>
<xml.dom.minidom.Document instance at 0x0172A3C8>
<DOM Element: properties at 0x1739378>
[u'id', u'name']
prop
1
[None]
>>>
-------------------
The source file is:
<?xml version="1.0" encoding="windows-1250"?>
<langfile>
<properties>
<form>
<component>
<prop id="aaaa" name ="bbbb">cccc</prop>
</component>
</form>
</properties>
<constants>
</constants>
</langfile>
-------------------
I can get the attrs, but I can't get nodeValue (cccc)... I got None for it.
Why???
Please help me a little!!! I'm sure that I miss st, but I don't know
what is that... :-(
Thanks for it:
dd
<?xml version="1.0" encoding="windows-1250"?>
<langfile>
<properties>
<form>
<component>
<prop id="aaaa" name ="bbbb">cccc</prop>
</component>
</form>
</properties>
<constants>
</constants>
</langfile>
--
http://mail.python.org/mailman/listinfo/python-list