xml - conversion of namespace to nodename in lxml - python -


i using lxml library... have tag in xml file called

<a:rpr lang="en-us" dirty="0" smtclean="0"/> , prefix a refers namespace

a="http://schemas.openxmlformats.org/drawingml/2006/main"^ 

when use lxml-xpath tag name a:rpr result {http://schemas.openxmlformats.org/drawingml/2006/main}rpr'

here code snippet have written:

if doc == 'file.xml':         file = etree.parse(my_directory+doc)         path = file.xpath('/p:sld/p:csld/p:sptree/p:sp/p:txbody/a:p/a:r/a:rpr', namespaces={'p':'http://schemas.openxmlformats.org/presentationml/2006/main',             'a':'http://schemas.openxmlformats.org/drawingml/2006/main'})         #print path         in path:             print a.tag 

i have used xml.minidom can use a.nodename tagname not have idea function give me tag name without namespace i.e a:rpr in lxml? in advance.

use xpath's name():

for in path:     print a.xpath('name()')  # prints a:rpr 

hope helps.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -