So extrahieren Sie Textinhalte unter einem XML-Tag mit beautifulsoupPython

Python-Programme
Anonymous
 So extrahieren Sie Textinhalte unter einem XML-Tag mit beautifulsoup

Post by Anonymous »

Ich habe eine XML-Datei, die so aussieht:

Code: Select all

Study design

This is a secondary analysis of the Childhood Acute Illness and Nutrition (CHAIN) Network prospective cohort which, between November 2016 and January 2019, recruited 3101 children at nine hospitals in Africa and South Asia: Dhaka and Matlab Hospitals (Bangladesh), Banfora Referral Hospital (Burkina Faso), Kilifi County, Mbagathi County and Migori County Hospitals (Kenya), Queen Elizabeth Hospital (Malawi), Civil Hospital (Pakistan), and Mulago National Referral Hospital (Uganda). As described in the published study protocol,

11

children were followed throughout hospital admission and after discharge with follow-up visits at 45, 90 and 180-days post-discharge. Catchment settings differed in urbanisation, access to health care and prevalence of background comorbidities such as HIV and malaria. Prior to study start, sites were audited to optimise care as per national and World Health Organisation (WHO) guidelines.

12

Cross-network harmonisation of clinical definitions and methods was prioritised through staff training and the use of standard operation procedures and case report forms (available online,
https://chainnetwork.org/resources/
).


Wie kann ich den Text im
-Element mit BeautifulSoup extrahieren?
Annäherung an dieses Problem mit Der folgende Code scheint nicht zu funktionieren.

Code: Select all

with open('test.xml', 'r') as file:
soup = BeautifulSoup(file, 'xml')

# Find and print all tags
for tag in soup.find_all('sec'):
print(tag.text)

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post