What the font bro? 😅 Can't read, I think I am too old
@fcento10 күн бұрын
😅
@debasishsahoo1268Ай бұрын
Awesome
@jdvelasquezr2 ай бұрын
Thank you, Francesco, for taking the time to review this library's different functions. You have greatly helped me finish a much-needed script for our localization engineering tasks. Notably, adding text to an existing tag saved the day.
@ShivModiShankar5 ай бұрын
Thanks for saving my day Francesco :)
@attilioturco5 ай бұрын
nice vid thanks
@AnEngineeringGirl6 ай бұрын
After editing the xml file, I don't want the ns tag in each line. What should I do?
@hoof-hearted-20246 ай бұрын
Can you show us how to parse a Tableau dashboard file (*.twb)? It's an XML file, Tableau just renamed it. I am trying to create a data dictionary from the .twb file.
@saranya5489 ай бұрын
Thank you Francesco for explaining this concept so easily with a demo.
@user-xu8od8tf9l10 ай бұрын
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.
@RodrigoMontes Жыл бұрын
Excellent man! This is what I was looking for :)
@equipagescatamaranlangrune8331 Жыл бұрын
Nice job Francesco, thank you. I do have a question regarding your last example. How do you get x.tag without the namespace in it ?
@bayrakmusti1 Жыл бұрын
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!
@nealrutgerskid Жыл бұрын
thank you
@5328csabi Жыл бұрын
Tried to find a solutuion on stackoverflow and other pages, and this video was the solution, good examples, good explanation with actual codes run. Thank you!
@stevemorse5052 Жыл бұрын
Francesco, thank you. Thanks to you I now somewhat understand what is happening in the XML file I have, I did not know that is contained name spaces. Within the first 6 minutes, I am writing this before I have read the comments or watched the whole video. You have saved me hours of coding as I was going to write my own parser. All the other video sorta, kinds, neglected this small detail! Now after reading the comments, I see you have helped a LOT of people, thank you again.
@narayanamurthyuppala6049 Жыл бұрын
Thanks a lot. It saved lot of my time
@aryan6536 Жыл бұрын
Have you stopped created videos?
@fcento Жыл бұрын
Is there anything in particular you would like to see? Been thinking to possibly do a video on CuPy
@jezhayes Жыл бұрын
Thank yopu so much, I was beginning to think I was cursed to manually write a text parser for these xml files forever.
@davidjnevin Жыл бұрын
Really excellent explanation. Thank you so much.
@maloman19892 жыл бұрын
Really cristal clear tutorial, I understand a lot of things I dindn't understand on XML namespaces, Thanks a lot Guy!
@giacomocillari44482 жыл бұрын
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?
@markdillon95882 жыл бұрын
can you mass edit multiple files?
@vvtwins4kidz2 жыл бұрын
this code is specific to specific xml, the code should be generic for any XML, if tags are missing it should add the missing tags
@aryan6536 Жыл бұрын
Surely you can use this information now to achieve many things, are you having any issues? Please share someone might be able ot help.
@skillbuilder1382 жыл бұрын
Hi, How to write the content of etree.dump to an xml file?
@UsmanSaadat2 жыл бұрын
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.
@vijayalakshmi82822 жыл бұрын
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
@A_A73372 жыл бұрын
Great video. Thanks
@sidjjj2 жыл бұрын
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)
@CinemagicMindset2 жыл бұрын
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
@fcento2 жыл бұрын
If you are sure the file you have is a valid xml (there are online tools to help you there), then what comes to mind is incorrect encoding. Check the documentation here: docs.python.org/3/library/xml.etree.elementtree.html#xml.etree.ElementTree.XMLParser
Let's take it in steps. I'm assuming you want to extract 'Entity', 'EntityTwo', 'EntityThree' from the element <Text> (...let me know if i misunderstood your question). The way it's formatted it contains 2 elements (<pp> and <cp>) as well as the piece of text you want to extract. If you just use findall() and use 'text' you get None back, what you want to use in this case is 'tail' instead. I've included a sample code here: gist.github.com/fcento100/74b8691af014a8126f8e9ca2ff03c6ea
@fcento2 жыл бұрын
i've put the xml code from your comment in a file here gist.github.com/fcento100/19cb7ae6b857c539a2c2843519239efc for convenience
@Gamer-mg6my2 жыл бұрын
@@fcento Yes, you understood me good. Ohhhh with tail .Well, i checked it but with other xml didn't compile :( , instead of that i put findall('.//cp', ns) and print elm.tail, with that we got the text. I like more your solution but with other xml didn't compile :(((((.This is the error that i got: elmtail = elm.tail.strip() AttributeError: 'NoneType' object has no attribute 'strip'
@fcento2 жыл бұрын
Apologies for not catching the 'NoneType' error, effectively 'tail' returns None if it doesn't find anything rather than an empty string. It's fixed now in this version: gist.github.com/fcento100/11847ad0d8d42eec6c1dc42de897b842 with an if statement to catch it. The reason i wasn't getting this error was because i copied pasted from your message and since it was formatted, 'tail' returned ' ' and '\t' (which are the string representation of new-line and tab) where it should have returned None, hence why i was able to run the strip command everywhere without error. In the new code i posted I've shown 2 methods of getting at that piece of data; in your sample xml "Entity" etc.. is the tail of <cp>; root.findall('.//visio:Text/',ns) and root.findall('.//visio:cp',ns) do similar things. The only difference is that using './/visio:Text/' in method 1 will also extract the tail for <pp> if is available, which may be undesirable! In that case './/visio:cp' like you suggested is the way to go.
@Gamer-mg6my2 жыл бұрын
@@fcento a lot of thanks for your kind help Francesco :))
@Gamer-mg6my2 жыл бұрын
Hi. I have this xmlns and i tried every solution and i can't read the XML with this namespace: <VisioDocument xmlns='urn:schemas-microsoft-com:office:visio'> ..... </VisioDocument> Some idea to solve this? :/ it is a xml, but the extension file is .vdx
@fcento2 жыл бұрын
Not enough information. What error do you get?
@Gamer-mg6my2 жыл бұрын
@@fcento hi thank you very much for your contributions, don't know why a while ago didn't compile but now it works, finally i do it with the solution that you recommended us on second 14:20
@IMMORTALmen2 жыл бұрын
Thank you! Spended almost two days trying to resolve namespace issue, and than found this video, thank you.
@stanleymbah89832 жыл бұрын
thank you for this
@vishalkalal222 жыл бұрын
Hi Francesco, In my xml closing tag is missing for example, Current xml - <data> <country name="Liechtenstein"> <rank>1</rank> <year>2008</year> <gdppc>141100</gdppc> <neighbor name="Austria" direction="E"/> <neighbor name="Switzerland" direction="W"/> </country> Expected xml - <data> <country name="Liechtenstein"> <rank>1</rank> <year>2008</year> <gdppc>141100</gdppc> <neighbor name="Austria" direction="E"/> <neighbor name="Switzerland" direction="W"/> </country> </data> Can you please help me with this?
@fcento2 жыл бұрын
If the closing tag is missing, it is technically an invalid file. You may have to manually close it yourself as there is no way for the code to know where it should be closed.
@AnilKumar234562 жыл бұрын
Vishal, you can use regex to find missing closed tag and then just replace it with desired closing tag
@myyoutubeaccount0123_2 жыл бұрын
thanks a lot
@fcento2 жыл бұрын
Happy to help
@kn72982 жыл бұрын
I know it's a bit late, but you can correct the XML layout after adding a new subelement by using the Indent method of ElementTree. This refreshes the automatic indent for the whole tree (or element). You may need to specify "space = ' '" (4 spaces) to override the default setting, to match the default layout for the dump method. ET.indent (tree, space = ' ') # for entire tree ET.indent (elm, space = ' ', level = 1) # for just the element although I did have problems with inconsistent spacing trying to just indent the element!! :O
@AlvaroMelchor2 жыл бұрын
Thanks, it's very clear, most of the tutorials cover only the non namespaces xml
@tessdejaeghere69722 жыл бұрын
Super helpful, thanks a lot!
@maxnoish2 жыл бұрын
Brilliant !!!
@LukasNachtigall2 жыл бұрын
Hey man! You just helped me to finish my parser! I do not know how, but I finally was able to find and change a text in each specific element in my XML file. I still do not understand, why I have to register the namespace, but it did the work perfectly. Your vide was really helpful. I didn't understood 70% of it for the 1st time, but now it's more clear to me. Thanks man!
@fcento2 жыл бұрын
Glad I could help!
@shrinivasulunandyala92692 жыл бұрын
Merge XML files using python,can you please make video on this top
@andrewbourne22962 жыл бұрын
That was SO helpful Dude. Thank you so much.
@rupeshbhuju28972 жыл бұрын
Hi Francesco Cento. I would like to know how to implement below two use cases 1) Incorrect type of data inside an element, for e.g string inside an element that is supposed to have an integer. 2) Missing element: An element that must be present according to XSD is not present in the XML. Could you please suggest any idea on this ? thanks
@fcento2 жыл бұрын
Rupesh, for your use case you may have to refer to a different library called “LXML” which has xml schema (XSD) support. I’m not experienced with this but looking at the documentation it has has an example on how to construct a validator which should address both your issues.
@rupeshbhuju28972 жыл бұрын
@@fcento Thank you for your suggestion. I will look into that more.
@GuitFishN2 жыл бұрын
This was a huge help. Thank you!
@thomasloia88742 жыл бұрын
Superb, exactly what I needed to know. Thank you
@arshap93513 жыл бұрын
Increase your font size before doing tutorials. its quite complicated to read texts. anyway goodjob
@prankurgarg66183 жыл бұрын
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>
@padraigmaccu93333 жыл бұрын
Go raibh céad maith agat, a Francesco. Rud a bhí de dhíth orm le fada. Pádraig Mac Con Uladh