Parsing XML with namespaces in Python using xml.etree.ElementTree - parsing xml document

preview_player
Показать описание

in this python video tutorial will i learn you how to parsing xml document with namespace and how you work with namespace in xml document in python.

you need to be sure you are running python3, this video will probly work in python2 but i have not testet it, and python2 will be outdated soon for updates.

🔔🔔🔔 SUBSCRIBE to get more great videos from me 🔔🔔🔔

🌟 Community 🌟

Github:
Рекомендации по теме
Комментарии
Автор

Thanks for this tutorial, it helped me great!

alexmak
Автор

Just what I was looking for, thank you.

scottyd
Автор

I was using Copilot AI, but Copilot was totally on wrong tracks with this issue. This helped a lot! Thank you!👍

masalli
Автор

Gracias de mucha utilidad tu video, saludos desde Colombia

carloszambrano
Автор

Great work, the most helpful video in lxml with namespaces! It´s cristal clear

maloman
Автор

Hi. I have a question though, as Namespaces have been causing me a massive pain


Say I have an xml like this and I want to get the value at both sets <SmpteTimeCode> tags...

<SOM>

</SOM>
<Duration>
<SmpteDuration>

</SmpteDuration>
</Duration>


... In this case I would need to use a more complex xpath such as './SOM/SmpteTimeCode' and when I iterate through the file. This is fine if there is no namespace. However if there is a namespace present the only way I have found to work with this is to either remove the namespace from the file, and stick with the path type detailed about OR alternatively I need to add the namespace to every element within the xpath, like so:

and

Is there a more elegant way of doing this?


I am aware that namespace can apparently be added as a 2nd argument to findall, however I cannot getting it working with xpaths like the above.




Any help is massively appreciated here


Cheers

joemurawski
Автор

Multiple namespaces....What is the use of programming if I am going copy-paste stuff from XML. It is dynamically scalable.

AnyFactor
Автор

Someone teach these people how to make fonts bigger

nk
Автор

Is it possible to remove namespaces apart from using xslt?

shivarajhj
Автор

This guy is just reading out and copying word to word from another example available on another website. I don't have a problem with that but I was looking for more examples

komalthecoolk
Автор

Parsing xml with lxml in python is fun. But trying to create an xml with namespaces is a big pain in the .... you know where ;-)

piotrbienkowski
Автор

Nice video. Now try root.findAll('ns1:name1/ns2:name2', namespace). That I cannot get to work. Basically two namespaces in a single query.

KangoV