无法从pubmed xml文件中读取所有抽象文本

2024-10-02 14:22:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我下载了一个pubmedxml文件,我想打印出这个文件中的所有文章。这是我的代码

import xml.etree.ElementTree as ET
tree = ET.parse('test1.xml')
root = tree.getroot()
for abs_1 in root.findall("PubmedArticle/MedlineCitation/Article/Abstract"):
    abs_2 = abs_1.find('AbstractText').text
    print(abs_2)

然而,我只得到了抽象的客观部分。这是标记为<AbstractText Label="AIM" NlmCategory="OBJECTIVE">,我没有得到另外两部分,也在<Abstract>

例如,XML得到了如下内容

<Abstract>
<AbstractText Label="AIM" NlmCategory="OBJECTIVE">The level of preparedness of the healthcare system plays an important role in management of coronavirus disease 2019 (COVID-19). This study attempted to devise a comprehensive protocol regarding dental care during the COVID-19 outbreak.</AbstractText>
<AbstractText Label="METHODS AND RESULT" NlmCategory="RESULTS">Embase, PubMed, and Google Scholar were searched until March 2020 for relevant papers. Sixteen English papers were enrolled to answer questions about procedures that are allowed to perform during the COVID-19 outbreak, patients who are in priority to receive dental care services, the conditions and necessities for patient admission, waiting room and operatory room, and personal protective equipment (PPE) that is necessary for dental clinicians and the office staff.</AbstractText>
<AbstractText Label="CONCLUSION" NlmCategory="CONCLUSIONS">Dental treatment should be limited to patients with urgent or emergency situation. By screening questionnaires for COVID-19, patients are divided into three groups of (a) apparently healthy, (b) suspected for COVID-19, and (c) confirmed for COVID-19. Separate waiting and operating rooms should be assigned to each group of patients to minimize the risk of disease transmission. All groups should be treated with the same protective measures with regard to PPE for the dental clinicians and staff.</AbstractText>
<CopyrightInformation>© 2020 Special Care Dentistry Association and Wiley Periodicals, Inc.</CopyrightInformation>
</Abstract>

使用我的代码,我只得到

The level of preparedness of the healthcare system plays an important role in management of coronavirus disease 2019 (COVID-19). This study attempted to devise a comprehensive protocol regarding dental care during the COVID-19 outbreak.

真的需要一些关于如何打印出摘要中所有摘要文本的帮助吗


Tags: andofthetoinabstractforabs
1条回答
网友
1楼 · 发布于 2024-10-02 14:22:33

当您可以使用.findall(){}元素时,您是否可以使用相同的方式使用.findall(){}元素

import xml.etree.ElementTree as ET

tree = ET.parse('test1.xml')
root = tree.getroot()

for AbstractText in root.findall("PubmedArticle/MedlineCitation/Article/Abstract/AbstractText"):
    print(AbstractText.text)

相关问题 更多 >