Home > Blockchain >  Python BeautifulSoup get content of tag with namespace
Python BeautifulSoup get content of tag with namespace

Time:01-27

I'm parsing a very large XML file that contains a lot of information separated by <entry> tags. Inside this tags there are other tags, the problem I have is that some of this contain namespaces and I found no way to access the information inside this tags using BeautifulSoup. An example of one element in the XML follows this:

<entry>
        <id>https://contrataciondelestado.es/sindicacion/licitacionesPerfilContratante/2750567</id>
        <link href="https://contrataciondelestado.es/wps/poc?uri=deeplink:detalle_licitacion&amp;idEvl=339fChNOkP8uf4aBO+vQlQ=="/>
        <summary type="text">Id licitación: AV 03008 18/20; Órgano de Contratación: Junta de Gobierno Local del Ayuntamiento de Ferrol; Importe: 90082.64 EUR; Estado: RES</summary>
        <title>Servicio de limpieza y mantenimiento de cubiertas y bajantes en los centros educativos de infantil y primaria</title>
        <updated>2019-09-27T11:59:01.365 02:00</updated>
        <cac-place-ext:ContractFolderStatus>
            <cbc:ContractFolderID>AV 03008 18/20</cbc:ContractFolderID>
            <cbc-place-ext:ContractFolderStatusCode languageID="es" listURI="https://contrataciondelestado.es/codice/cl/2.04/SyndicationContractFolderStatusCode-2.04.gc">RES</cbc-place-ext:ContractFolderStatusCode>
            <cac-place-ext:LocatedContractingParty>
                <cbc:ContractingPartyTypeCode listURI="http://contrataciondelestado.es/codice/cl/1.04/ContractingAuthorityCode-1.04.gc">3</cbc:ContractingPartyTypeCode>
                <cac:Party>
                    <cbc:WebsiteURI>https://www.ferrol.gal/</cbc:WebsiteURI>
                    <cac:PartyIdentification>
                        <cbc:ID schemeName="DIR3">L01150367</cbc:ID>
                    </cac:PartyIdentification>
                    <cac:PartyIdentification>
                        <cbc:ID schemeName="NIF">P1503700E</cbc:ID>
                    </cac:PartyIdentification>
                    <cac:PartyName>
                        <cbc:Name>Junta de Gobierno Local del Ayuntamiento de Ferrol</cbc:Name>
                    </cac:PartyName>
                    <cac:PostalAddress>
                        <cbc:CityName>Ferrol</cbc:CityName>
                        <cbc:PostalZone>15402</cbc:PostalZone>
                        <cac:AddressLine>
                            <cbc:Line>Plaza de Armas S/N</cbc:Line>
                        </cac:AddressLine>
                        <cac:Country>
                            <cbc:IdentificationCode listURI="http://docs.oasis-open.org/ubl/os-ubl-2.0/cl/gc/default/CountryIdentificationCode-2.0.gc">ES</cbc:IdentificationCode>
                            <cbc:Name>España</cbc:Name>
                        </cac:Country>
                    </cac:PostalAddress>
                    <cac:Contact>
                        <cbc:Name>Junta de Gobierno Local del Ayuntamiento de Ferrol</cbc:Name>
                        <cbc:ElectronicMail>[email protected]</cbc:ElectronicMail>
                    </cac:Contact>
                </cac:Party>
            </cac-place-ext:LocatedContractingParty>
            <cac:ProcurementProject>
                <cbc:Name>Servicio de limpieza y mantenimiento de cubiertas y bajantes en los centros educativos de infantil y primaria</cbc:Name>
                <cbc:TypeCode listURI="http://contrataciondelestado.es/codice/cl/2.08/ContractCode-2.08.gc">2</cbc:TypeCode>
                <cbc:SubTypeCode listURI="http://contrataciondelestado.es/codice/cl/1.04/ServiceContractCode-1.04.gc">1</cbc:SubTypeCode>
                <cac:BudgetAmount>
                    <cbc:EstimatedOverallContractAmount currencyID="EUR">188155.38</cbc:EstimatedOverallContractAmount>
                    <cbc:TotalAmount currencyID="EUR">109000</cbc:TotalAmount>
                    <cbc:TaxExclusiveAmount currencyID="EUR">90082.64</cbc:TaxExclusiveAmount>
                </cac:BudgetAmount>
                <cac:RequiredCommodityClassification>
                    <cbc:ItemClassificationCode listURI="http://contrataciondelestado.es/codice/cl/1.04/CPV2007-1.04.gc">45261900</cbc:ItemClassificationCode>
                </cac:RequiredCommodityClassification>
                <cac:RealizedLocation>
                    <cbc:CountrySubentity>A Coruña</cbc:CountrySubentity>
                    <cbc:CountrySubentityCode listURI="http://contrataciondelestado.es/codice/cl/2.06/NUTS-2016.gc">ES111</cbc:CountrySubentityCode>
                    <cac:Address>
                        <cac:Country>
                            <cbc:IdentificationCode listURI="http://docs.oasis-open.org/ubl/os-ubl-2.0/cl/gc/default/CountryIdentificationCode-2.0.gc">ES</cbc:IdentificationCode>
                            <cbc:Name>España</cbc:Name>
                        </cac:Country>
                    </cac:Address>
                </cac:RealizedLocation>
                <cac:PlannedPeriod>
                    <cbc:DurationMeasure unitCode="ANN">2</cbc:DurationMeasure>
                </cac:PlannedPeriod>
                <cac:ContractExtension>
                    <cac:OptionValidityPeriod>
                        <cbc:Description>Prorrogable anualmente hasta un máximo de dos años, conforme a lo especificado en el artículo 29.2 LCSP, sin que la duración total incluidas las prórrogas pueda exceder de 4 años (2 1 1) .
Ver apartado 7 del Anexo I del PCAP.</cbc:Description>
                    </cac:OptionValidityPeriod>
                </cac:ContractExtension>
            </cac:ProcurementProject>
            <cac:TenderResult>
                <cbc:ResultCode listURI="http://contrataciondelestado.es/codice/cl/2.02/TenderResultCode-2.02.gc">8</cbc:ResultCode>
                <cbc:Description>Se adjudica el contrato a la única oferta admitida a la licitación, que cumple los requisitos de los pliegos.</cbc:Description>
                <cbc:AwardDate>2019-04-29</cbc:AwardDate>
                <cbc:ReceivedTenderQuantity>2</cbc:ReceivedTenderQuantity>
                <cbc:LowerTenderAmount currencyID="EUR">55131.7</cbc:LowerTenderAmount>
                <cbc:HigherTenderAmount currencyID="EUR">55131.7</cbc:HigherTenderAmount>
                <cbc:StartDate>2019-09-27</cbc:StartDate>
                <cac:Contract>
                    <cbc:ID>2057</cbc:ID>
                    <cbc:IssueDate>2019-09-26</cbc:IssueDate>
                </cac:Contract>
                <cac:WinningParty>
                    <cac:PartyIdentification>
                        <cbc:ID schemeName="NIF">B74282781</cbc:ID>
                    </cac:PartyIdentification>
                    <cac:PartyName>
                        <cbc:Name>CYS HISPANIA S.L.</cbc:Name>
                    </cac:PartyName>
                </cac:WinningParty>
                <cac:AwardedTenderedProject>
                    <cac:LegalMonetaryTotal>
                        <cbc:TaxExclusiveAmount currencyID="EUR">55131.7</cbc:TaxExclusiveAmount>
                        <cbc:PayableAmount currencyID="EUR">66709.36</cbc:PayableAmount>
                    </cac:LegalMonetaryTotal>
                </cac:AwardedTenderedProject>
            </cac:TenderResult>
            <cac:TenderingTerms>
                <cbc:RequiredCurriculaIndicator>false</cbc:RequiredCurriculaIndicator>
                <cbc:VariantConstraintIndicator>false</cbc:VariantConstraintIndicator>
                <cac:RequiredFinancialGuarantee>
                    <cbc:GuaranteeTypeCode listURI="http://contrataciondelestado.es/codice/cl/1.04/GuaranteeTypeCode-1.04.gc">2</cbc:GuaranteeTypeCode>
                    <cbc:AmountRate>5</cbc:AmountRate>
                </cac:RequiredFinancialGuarantee>
                <cac:TendererQualificationRequest>
                    <cbc:Description>Para optar a la presente licitación no resulta exigible clasificación, de conformidad con lo establecido en el artículo 77.1 b) de la Ley 9/2017 de Contratos del Sector Público.

No obstante los licitadores podrán acreditar su solvencia económica y financiera y técnica o profesional a través de la siguiente clasificación: GRUPO O, SUBGRUPO 1, CATEGORÍA 1.

Ver apartado 11.3. del Anexo I del PCAP: Compromiso de adscripción de medios.</cbc:Description>
                    <cac:TechnicalEvaluationCriteria>
                        <cbc:EvaluationCriteriaTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.0/TechnicalCapabilityTypeCode-2.0.gc">OXR-MEDIOS</cbc:EvaluationCriteriaTypeCode>
                        <cbc:Description>Ver apartado 11 del Anexo I del PCAP.</cbc:Description>
                    </cac:TechnicalEvaluationCriteria>
                    <cac:TechnicalEvaluationCriteria>
                        <cbc:EvaluationCriteriaTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.0/TechnicalCapabilityTypeCode-2.0.gc">OSR-COMPTASK</cbc:EvaluationCriteriaTypeCode>
                        <cbc:Description>Ver apartado 11 del Anexo I del PCAP.</cbc:Description>
                    </cac:TechnicalEvaluationCriteria>
                    <cac:FinancialEvaluationCriteria>
                        <cbc:EvaluationCriteriaTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.0/FinancialCapabilityTypeCode-2.0.gc">5</cbc:EvaluationCriteriaTypeCode>
                        <cbc:Description>Ver apartado 11 del Anexo I del PCAP.</cbc:Description>
                    </cac:FinancialEvaluationCriteria>
                    <cac:SpecificTendererRequirement>
                        <cbc:RequirementTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.0/DeclarationTypeCode-2.0.gc">4</cbc:RequirementTypeCode>
                    </cac:SpecificTendererRequirement>
                    <cac:SpecificTendererRequirement>
                        <cbc:RequirementTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.0/DeclarationTypeCode-2.0.gc">3</cbc:RequirementTypeCode>
                    </cac:SpecificTendererRequirement>
                    <cac:SpecificTendererRequirement>
                        <cbc:RequirementTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.0/DeclarationTypeCode-2.0.gc">1</cbc:RequirementTypeCode>
                    </cac:SpecificTendererRequirement>
                    <cac:SpecificTendererRequirement>
                        <cbc:RequirementTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.0/DeclarationTypeCode-2.0.gc">2</cbc:RequirementTypeCode>
                    </cac:SpecificTendererRequirement>
                    <cac:SpecificTendererRequirement>
                        <cbc:RequirementTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.0/DeclarationTypeCode-2.0.gc">5</cbc:RequirementTypeCode>
                    </cac:SpecificTendererRequirement>
                </cac:TendererQualificationRequest>
                <cac:AllowedSubcontractTerms>
                    <cbc:Rate>60</cbc:Rate>
                    <cbc:Description>Ver apartado 21 del Anexo I del PCAP.</cbc:Description>
                </cac:AllowedSubcontractTerms>
                <cac:AwardingTerms>
                    <cac:AwardingCriteria>
                        <cbc:Description>Memoria técnica</cbc:Description>
                        <cbc:WeightNumeric>20</cbc:WeightNumeric>
                    </cac:AwardingCriteria>
                    <cac:AwardingCriteria>
                        <cbc:Description>Oferta económica</cbc:Description>
                        <cbc:WeightNumeric>75</cbc:WeightNumeric>
                    </cac:AwardingCriteria>
                    <cac:AwardingCriteria>
                        <cbc:Description>Calidad medioambiental</cbc:Description>
                        <cbc:WeightNumeric>5</cbc:WeightNumeric>
                    </cac:AwardingCriteria>
                </cac:AwardingTerms>
                <cac:Language>
                    <cbc:ID>es</cbc:ID>
                </cac:Language>
            </cac:TenderingTerms>
            <cac:TenderingProcess>
                <cbc:ProcedureCode listURI="https://contrataciondelestado.es/codice/cl/2.07/SyndicationTenderingProcessCode-2.07.gc">1</cbc:ProcedureCode>
                <cbc:UrgencyCode listURI="http://contrataciondelestado.es/codice/cl/1.04/DiligenceTypeCode-1.04.gc">1</cbc:UrgencyCode>
                <cbc:SubmissionMethodCode listURI="http://contrataciondelestado.es/codice/cl/1.04/TenderDeliveryCode-1.04.gc">2</cbc:SubmissionMethodCode>
                <cac:DocumentAvailabilityPeriod>
                    <cbc:EndDate>2018-12-26</cbc:EndDate>
                    <cbc:EndTime>14:00:00</cbc:EndTime>
                </cac:DocumentAvailabilityPeriod>
                <cac:TenderSubmissionDeadlinePeriod>
                    <cbc:EndDate>2018-12-26</cbc:EndDate>
                    <cbc:EndTime>14:00:00</cbc:EndTime>
                </cac:TenderSubmissionDeadlinePeriod>
                <cac:AuctionTerms>
                    <cbc:AuctionConstraintIndicator>false</cbc:AuctionConstraintIndicator>
                </cac:AuctionTerms>
            </cac:TenderingProcess>
            <cac:LegalDocumentReference>
                <cbc:ID>PCAP.pdf</cbc:ID>
                <cac:Attachment>
                    <cac:ExternalReference>
                        <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=a9aced4a-576a-46c7-aa86-fb9ef9514ebe</cbc:URI>
                        <cbc:DocumentHash>0DYyjGaHBEFBUHN12T8LXWFqQ4Y=</cbc:DocumentHash>
                    </cac:ExternalReference>
                </cac:Attachment>
            </cac:LegalDocumentReference>
            <cac:TechnicalDocumentReference>
                <cbc:ID>PPT.pdf</cbc:ID>
                <cac:Attachment>
                    <cac:ExternalReference>
                        <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=a2de6f58-eed7-488f-b08a-dad4c1537561</cbc:URI>
                        <cbc:DocumentHash>vU3KYJ9Zcqu8ba7ooIHTaBJRN48=</cbc:DocumentHash>
                    </cac:ExternalReference>
                </cac:Attachment>
            </cac:TechnicalDocumentReference>
            <cac-place-ext:ValidNoticeInfo>
                <cbc-place-ext:NoticeTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.04/TenderingNoticeTypeCode-2.04.gc">DOC_CAN_ADJ</cbc-place-ext:NoticeTypeCode>
                <cac-place-ext:AdditionalPublicationStatus>
                    <cbc-place-ext:PublicationMediaName>Perfil del Contratante</cbc-place-ext:PublicationMediaName>
                    <cac-place-ext:AdditionalPublicationDocumentReference>
                        <cbc:IssueDate>2019-05-03</cbc:IssueDate>
                    </cac-place-ext:AdditionalPublicationDocumentReference>
                    <cac-place-ext:AdditionalPublicationDocumentReference>
                        <cbc:IssueDate>2019-05-06</cbc:IssueDate>
                    </cac-place-ext:AdditionalPublicationDocumentReference>
                    <cac-place-ext:AdditionalPublicationDocumentReference>
                        <cbc:DocumentTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.06/TenderingDocumentTypeCode-2.06.gc" name="Documento de Acta de Adjudicación">ACTA_ADJ</cbc:DocumentTypeCode>
                        <cac:Attachment>
                            <cac:ExternalReference>
                                <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=61a4643f-b107-49f6-82e1-3880368f5ea0</cbc:URI>
                                <cbc:FileName>Acuerdo adjudicacion AV 18-20.pdf</cbc:FileName>
                            </cac:ExternalReference>
                        </cac:Attachment>
                    </cac-place-ext:AdditionalPublicationDocumentReference>
                </cac-place-ext:AdditionalPublicationStatus>
            </cac-place-ext:ValidNoticeInfo>
            <cac-place-ext:ValidNoticeInfo>
                <cbc-place-ext:NoticeTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.04/TenderingNoticeTypeCode-2.04.gc">DOC_CD</cbc-place-ext:NoticeTypeCode>
                <cac-place-ext:AdditionalPublicationStatus>
                    <cbc-place-ext:PublicationMediaName>Perfil del Contratante</cbc-place-ext:PublicationMediaName>
                    <cac-place-ext:AdditionalPublicationDocumentReference>
                        <cbc:IssueDate>2018-12-07</cbc:IssueDate>
                    </cac-place-ext:AdditionalPublicationDocumentReference>
                </cac-place-ext:AdditionalPublicationStatus>
            </cac-place-ext:ValidNoticeInfo>
            <cac-place-ext:ValidNoticeInfo>
                <cbc-place-ext:NoticeTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.04/TenderingNoticeTypeCode-2.04.gc">DOC_CN</cbc-place-ext:NoticeTypeCode>
                <cac-place-ext:AdditionalPublicationStatus>
                    <cbc-place-ext:PublicationMediaName>Perfil del Contratante</cbc-place-ext:PublicationMediaName>
                    <cac-place-ext:AdditionalPublicationDocumentReference>
                        <cbc:IssueDate>2018-12-07</cbc:IssueDate>
                    </cac-place-ext:AdditionalPublicationDocumentReference>
                    <cac-place-ext:AdditionalPublicationDocumentReference>
                        <cbc:IssueDate>2019-01-11</cbc:IssueDate>
                    </cac-place-ext:AdditionalPublicationDocumentReference>
                    <cac-place-ext:AdditionalPublicationDocumentReference>
                        <cbc:IssueDate>2019-01-18</cbc:IssueDate>
                    </cac-place-ext:AdditionalPublicationDocumentReference>
                </cac-place-ext:AdditionalPublicationStatus>
            </cac-place-ext:ValidNoticeInfo>
            <cac-place-ext:ValidNoticeInfo>
                <cbc-place-ext:NoticeTypeCode listURI="http://contrataciondelestado.es/codice/cl/2.04/TenderingNoticeTypeCode-2.04.gc">DOC_FORM</cbc-place-ext:NoticeTypeCode>
                <cac-place-ext:AdditionalPublicationStatus>
                    <cbc-place-ext:PublicationMediaName>Perfil del Contratante</cbc-place-ext:PublicationMediaName>
                    <cac-place-ext:AdditionalPublicationDocumentReference>
                        <cbc:IssueDate>2019-09-27</cbc:IssueDate>
                    </cac-place-ext:AdditionalPublicationDocumentReference>
                </cac-place-ext:AdditionalPublicationStatus>
            </cac-place-ext:ValidNoticeInfo>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>1bd13a0f-453a-4485-aff6-1ea141a389cc</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=1bd13a0f-453a-4485-aff6-1ea141a389cc</cbc:URI>
                            <cbc:FileName>Visita instalaciones</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>542444d6-7978-4f3b-8c8f-0d4a33863965</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=542444d6-7978-4f3b-8c8f-0d4a33863965</cbc:URI>
                            <cbc:FileName>Documento de aprobación del expediente</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>5b537d77-8c3b-4356-a06d-0a033461a3bd</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=5b537d77-8c3b-4356-a06d-0a033461a3bd</cbc:URI>
                            <cbc:FileName>Informe de insuficiencia de medios</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>c5cd2ab9-c1d1-490c-9f91-7996a623773e</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=c5cd2ab9-c1d1-490c-9f91-7996a623773e</cbc:URI>
                            <cbc:FileName>Memoria justificativa</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>0a5986d5-a17a-484d-87ba-a57901959cd9</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=0a5986d5-a17a-484d-87ba-a57901959cd9</cbc:URI>
                            <cbc:FileName>Composición de la mesa de contratación</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>582eede0-b53a-43d6-9943-7e9fda493b9a</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=582eede0-b53a-43d6-9943-7e9fda493b9a</cbc:URI>
                            <cbc:FileName>Justificacion de presupuesto</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>7fc2c308-70c3-45a1-9c4b-557dffdb3ca1</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=7fc2c308-70c3-45a1-9c4b-557dffdb3ca1</cbc:URI>
                            <cbc:FileName>Acta del órgano de asistencia</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>749c4d74-981d-4ff2-ba4c-4927ebe8448d</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=749c4d74-981d-4ff2-ba4c-4927ebe8448d</cbc:URI>
                            <cbc:FileName>Acta del órgano de asistencia</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>6d7c55f5-e922-4f64-a213-97e083d091b4</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=6d7c55f5-e922-4f64-a213-97e083d091b4</cbc:URI>
                            <cbc:FileName>Acta del órgano de asistencia</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>731e93d8-fd52-41fd-8139-42473981e055</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=731e93d8-fd52-41fd-8139-42473981e055</cbc:URI>
                            <cbc:FileName>Informe sobre las ofertas incursas en presunción de anormalidad</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>339a52fd-d727-46f5-8012-b5c6d2ba98cd</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=339a52fd-d727-46f5-8012-b5c6d2ba98cd</cbc:URI>
                            <cbc:FileName>Informe sobre las ofertas incursas en presunción de anormalidad</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
            <cac-place-ext:GeneralDocument>
                <cac-place-ext:GeneralDocumentDocumentReference>
                    <cbc:ID>cd9c1c9b-7c49-46f1-a8f4-60630314322e</cbc:ID>
                    <cac:Attachment>
                        <cac:ExternalReference>
                            <cbc:URI>https://contrataciondelestado.es/wps/wcm/connect/PLACE_es/Site/area/docAccCmpnt?srv=cmpnt&amp;cmpntname=GetDocumentsById&amp;source=library&amp;DocumentIdParam=cd9c1c9b-7c49-46f1-a8f4-60630314322e</cbc:URI>
                            <cbc:FileName>Acta del órgano de asistencia</cbc:FileName>
                        </cac:ExternalReference>
                    </cac:Attachment>
                </cac-place-ext:GeneralDocumentDocumentReference>
            </cac-place-ext:GeneralDocument>
        </cac-place-ext:ContractFolderStatus>
    </entry>

Right now I'm trying to access the information contained on tag cbc:EstimatedOverallContractAmount, my code looks like this right now:

from bs4 import BeautifulSoup

soup = BeautifulSoup(file, 'lxml')
items = soup.findAll('entry')

for idx, item in enumerate(items):
    if idx == 0:
        print(item)

Right now I'm just testing, so I'm just trying to display different information from the first element in console with the print. For example, if I want the information from the <title> tag, a simple print(item.title) works just find, but I don't know how to get the info from the ones with namespaces, since I can't do print(item.cbc:EstimatedOverallContractAmount).

Searching I found this post, but since item inside the for loop is not a BeautifulSoup element, I can't do an item.find(cbc:EstimatedOverallContractAmount).

How can I access it?

CodePudding user response:

You need to use all lowercase letters:

from bs4 import BeautifulSoup

soup = BeautifulSoup(xmltext, 'lxml')
items = soup.findAll('entry')

for idx, item in enumerate(items):
    if idx == 0:
        print(item.find('cbc:estimatedoverallcontractamount'))

Output:

<cbc:estimatedoverallcontractamount currencyid="EUR">188155.38</cbc:estimatedoverallcontractamount>
  • Related