Parsing XML document with namespaces in Python

Published: 05 November 2024
on channel: Emrah KAYA
11
0

Hello everyone! I hope this video has helped solve your questions and issues. This video is shared because a solution has been found for the question/problem. I create videos for questions that have solutions. If you have any other issues, feel free to reach out to me on Instagram:   / ky.emrah  

Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!Parsing XML document with namespaces in Python

I am trying to parse xml with namespace and attributes.
I'm using XML library in Python and since I'm new with this, cannot find solution even I checked over this forum, there are similar questions but not same structure of XML document as I have.
This is my XML:
?xml version='1.0' encoding='UTF-8'?
Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-inst..." xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sbt="http://mfin.gov.rs/srbdt/srbdtext" xmlns:urn="oasis:names:specification:ubl:schema:xsd:Invoice-2"
cbc:ID IF149-0111/24 /cbc:ID
cac:InvoiceLine
cbc:ID 1 /cbc:ID
cbc:InvoicedQuantity unitCode="H87" 3.00 /cbc:InvoicedQuantity
cbc:LineExtensionAmount currencyID="RSD" 26574.00 /cbc:LineExtensionAmount
cac:TaxTotal
cbc:TaxAmount currencyID="RSD" 5314.80 /cbc:TaxAmount
cac:TaxSubtotal
cbc:TaxAmount currencyID="RSD" 5314.800 /cbc:TaxAmount
cbc:Percent 20.0 /cbc:Percent
cac:TaxCategory
cbc:ID S /cbc:ID
cbc:Name 20% /cbc:Name
cbc:Percent 20.0 /cbc:Percent
/cac:TaxCategory
/cac:TaxSubtotal
/cac:TaxTotal
cac:Item
cbc:Description [P11190420] Toner Cartridge Brother DCP5500/MFC L 5700/6800 TN3410/3480 Katun Select /cbc:Description
cbc:Name [P11190420] Toner Cartridge Brother DCP5500/MFC L 5700/6800 TN3410/3480 Katun Select /cbc:Name
cac:ClassifiedTaxCategory
cbc:ID S /cbc:ID
cbc:Name 20% /cbc:Name
cbc:Percent 20.0 /cbc:Percent
/cac:ClassifiedTaxCategory
/cac:Item
/cac:InvoiceLine
cac:InvoiceLine
cbc:ID 2 /cbc:ID
cbc:InvoicedQuantity unitCode="H87" 1.00 /cbc:InvoicedQuantity
cbc:LineExtensionAmount currencyID="RSD" 600.00 /cbc:LineExtensionAmount
cac:TaxTotal
cbc:TaxAmount currencyID="RSD" 120.00 /cbc:TaxAmount
cac:TaxSubtotal
cbc:TaxAmount currencyID="RSD" 120.000 /cbc:TaxAmount
cbc:Percent 20.0 /cbc:Percent
cac:TaxCategory
cbc:ID S /cbc:ID
cbc:Name 20% /cbc:Name
cbc:Percent 20.0 /cbc:Percent
cbc:TaxExemptionReason /cbc:TaxExemptionReason
cac:TaxScheme
cbc:ID schemeID="UN/ECE 5153" schemeAgencyID="6" VAT /cbc:ID
/cac:TaxScheme
/cac:TaxCategory
/cac:TaxSubtotal
/cac:TaxTotal
cac:Item
cbc:Description [U11124116] Usluga transporta /cbc:Description
cbc:Name [U11124116] Usluga transporta /cbc:Name
cac:SellersItemIdentification
cbc:ID U11124116 /cbc:ID
/cac:SellersItemIdentification
cac:ClassifiedTaxCategory
cbc:ID S /cbc:ID
cbc:Name 20% /cbc:Name
cbc:Percent 20.0 /cbc:Percent
cbc:TaxExemptionReason /cbc:TaxExemptionReason
cac:TaxScheme
cbc:ID schemeID="UN/ECE 5153" schemeAgencyID="6" VAT /cbc:ID
/cac:TaxScheme
/cac:ClassifiedTaxCategory
/cac:Item
cac:Price
cbc:PriceAmount currencyID="RSD" 600.00 /cbc:PriceAmount
cbc:BaseQuantity unSource of the question:
https://stackoverflow.com/questions/7...

Question and source license information:
https://meta.stackexchange.com/help/l...
https://stackoverflow.com/


On this page of the site you can watch the video online Parsing XML document with namespaces in Python with a duration of hours minute second in good quality, which was uploaded by the user Emrah KAYA 05 November 2024, share the link with friends and acquaintances, this video has already been watched 11 times on youtube and it was liked by 0 viewers. Enjoy your viewing!