Parsing XML files with Python (xml.etree.ElementTree)

Parsing XML files with Python (xml.etree.ElementTree)

Francesco Cento

3 года назад

72,361 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@user-xu8od8tf9l
@user-xu8od8tf9l - 19.09.2023 19:18

Thanks a lot for the great tutorial. Your approach to XML parsing was spot-on for me and it was exactly what I was looking for to get started on XML parsing.

Ответить
@Eduard-ne2ff
@Eduard-ne2ff - 06.07.2023 19:23

shitty video, sorry

Ответить
@RodrigoMontes
@RodrigoMontes - 25.04.2023 10:06

Excellent man!
This is what I was looking for :)

Ответить
@bayrakmusti1
@bayrakmusti1 - 27.03.2023 01:38

That's how it is supposed to be taught. I have been browsing the courses on how to do it and they all are complicated. Thankfully found this video. Thanks a lot. Great job!

Ответить
@giacomocillari4448
@giacomocillari4448 - 10.07.2022 18:18

Is there a way to change sub-element instead of the whole element string? let's say for example that I want to change W with SW but not the name, and I need to do it in a loop so I can't put the name string inside as it changes anytime, is there a way to call the specific sub element?

Ответить
@markdillon9588
@markdillon9588 - 29.06.2022 20:34

can you mass edit multiple files?

Ответить
@UsmanSaadat
@UsmanSaadat - 14.06.2022 15:21

Thanks a lot for this video. I couldn't grasp the concepts properly even after reading from books. This video made it look like piece of cake.

Ответить
@vijayalakshmi8282
@vijayalakshmi8282 - 26.04.2022 09:16

hii franseco great video thanks i need small suggestion here let's saya <KTOPL> 100</KTOPL> so in this i need output like KTOPL 100 here i need tag and value both how we can get can u please explian

Ответить
@afad287
@afad287 - 21.04.2022 01:08

Great video. Thanks

Ответить
@sidjjj
@sidjjj - 03.04.2022 22:19

Thanks for this video, I needed to parse xml from a variable instead of a file and found this : xml_data_tree = ET.fromstring(received_packet)

Ответить
@CinemagicMindset
@CinemagicMindset - 24.03.2022 20:08

Hi Francesco,
i'm getting error while parsing xml file since it is having special words. kindly hep me to avoid this error.
Error : xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 277, column 366

Ответить
@stanleymbah8983
@stanleymbah8983 - 14.03.2022 15:46

thank you for this

Ответить
@dogancantop9848
@dogancantop9848 - 10.02.2022 12:54

thanks a lot

Ответить
@shrinivasulunandyala9269
@shrinivasulunandyala9269 - 21.10.2021 09:08

Merge XML files using python,can you please make video on this top

Ответить
@arshap9351
@arshap9351 - 25.07.2021 06:57

Increase your font size before doing tutorials. its quite complicated to read texts. anyway goodjob

Ответить
@prankurgarg6618
@prankurgarg6618 - 12.07.2021 14:05

Hi Francesco, Thanks for sharing your knowledge with us. I have a doubt if we want to get a element based on the value of other element , how can we do. I want if attachment is local, print symid. Can you or someone else here please help me here.
<?xml version="1.0" standalone="yes" ?>
<SymCLI_ML>
<Box>
<Symm_Info>
<symid>000120000369</symid>
<attachment>Local</attachment>
<model>model1</model>
<microcode_version>6079</microcode_version>
<cache_megabytes>250880</cache_megabytes>
<cache_gigabytes>245.0</cache_gigabytes>
<devices>8532</devices>
<physical_devices>502</physical_devices>
</Symm_Info>
</Box>
<Box>
<Symm_Info>
<symid>000120000566</symid>
<attachment>Local</attachment>
<model>model2</model>
<microcode_version>6079</microcode_version>
<cache_megabytes>520192</cache_megabytes>
<cache_gigabytes>508.0</cache_gigabytes>
<devices>10391</devices>
<physical_devices>512</physical_devices>
</Symm_Info>
</Box>
<Box>
<Symm_Info>
<symid>000120000568</symid>
<attachment>Local</attachment>
<model>model3</model>
<microcode_version>6079</microcode_version>
<cache_megabytes>165888</cache_megabytes>
<cache_gigabytes>162.0</cache_gigabytes>
<devices>19444</devices>
<physical_devices>880</physical_devices>
</Symm_Info>
</Box>
</SymCLI_ML>

Ответить
@padraigmaccu9333
@padraigmaccu9333 - 04.07.2021 17:26

Go raibh céad maith agat, a Francesco. Rud a bhí de dhíth orm le fada. Pádraig Mac Con Uladh

Ответить
@KrishnaManohar8021
@KrishnaManohar8021 - 28.06.2021 09:51

looking forword...

Ответить
@RS-el7iu
@RS-el7iu - 06.02.2021 14:41

thanks a lot ❤

Ответить
@KiviliG
@KiviliG - 01.02.2021 05:07

Can this be done by Beautifulsoup library?

Ответить
@arnolda7417
@arnolda7417 - 20.01.2021 17:59

Hi Francesco. Thanks for the great video! I ran into an error after editing my xml file. I tried to view the entire file to make sure my changes were made with ET.dump(tree) and I always get "AttributeError: 'str' object has no attribute 'items'" I'm testing with Jupyter notebook and when I restart the kernel, ET.dump works just fine before I make changes to the file. Any idea on how to fix this? I'm new to Python.

Ответить
@ginopeduto4264
@ginopeduto4264 - 12.01.2021 17:10

Grazie Mille!!! That was exactly what I was looking for and all well explained!!!

Ответить
@hoscoharding7319
@hoscoharding7319 - 01.11.2020 22:16

Hi Francesco! I have been trying to do something with elementtree for several days but it is impossible for me ... And it gives me the feeling that it is very simple. I want to make a little script that adds a child element only if it doesn't already have it. Imagine that the document lacks year to panama. My script would go through the xml document and add only the year to Panama ... Could you give me some idea please?
Many thanks.

Ответить
@fantasticprajwal7442
@fantasticprajwal7442 - 15.09.2020 18:22

How to install xmltree in python 2.7.5
I am not able to upgrade due to restriction

Ответить