List Info

Thread: getAttribute




getAttribute
user name
2006-03-31 10:58:34
Hello all,

Could anyone help me by giving example of getAttribute

xmldata = ziparchive.read("content.xml")
xmldoc = minidom.parseString(xmldata)
officeNode = xmldoc.getElementsByTagName('office:text')

I have another function:
def go_thru (nodelist):
    for x in range(nodelist.length):
        node = nodelist[x]
        i = 0
        print node.getAttribute('text:style-name')

go_thru(officeNode) #Calling function

I always get error message: AttributeError: Text instance
has no
attribute 'getAttribute'
Could anyone give an explanation?

Thanks a lot,

da

_______________________________________________
Tutor maillist  -  Tutorpython.org
http://
mail.python.org/mailman/listinfo/tutor
getAttribute
user name
2006-03-31 13:14:53
kakada wrote:
> Hello all,
> 
> Could anyone help me by giving example of getAttribute
> 
> xmldata = ziparchive.read("content.xml")
> xmldoc = minidom.parseString(xmldata)
> officeNode =
xmldoc.getElementsByTagName('office:text')
> 
> I have another function:
> def go_thru (nodelist):
>     for x in range(nodelist.length):
>         node = nodelist[x]
>         i = 0
>         print node.getAttribute('text:style-name')
> 
> go_thru(officeNode) #Calling function
> 
> I always get error message: AttributeError: Text
instance has no
> attribute 'getAttribute'
> Could anyone give an explanation?

I think it should be
node.attributes['text:style-name'].nodeValue.

You might want to look at ElementTree, it is a more Pythonic
XML library.

Kent

_______________________________________________
Tutor maillist  -  Tutorpython.org
http://
mail.python.org/mailman/listinfo/tutor
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )