解析XML的Python帮助

2024-09-30 05:22:38 发布

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

我想编写Python代码,将以下XML文件更改为PubTator格式。你知道吗

XML代码:

<?xml version="1.0"?>
<!DOCTYPE PubmedArticleSet PUBLIC "-//NLM//DTD PubMedArticle, 1st January 2016//EN" "http://www.ncbi.nlm.nih.gov/corehtml/query/DTD/pubmed_160101.dtd">
<PubmedArticleSet>

<PubmedArticle>
    <MedlineCitation Owner="NLM" Status="In-Data-Review">
        ***<PMID Version="1">***26959637</PMID>
        <DateCreated>
            <Year>2016</Year>
            <Month>03</Month>
            <Day>10</Day>
        </DateCreated>
        <Article PubModel="Print">
            <Journal>
                <ISSN IssnType="Print">1334-4366</ISSN>
                <JournalIssue CitedMedium="Print">
                    <Volume>13 Suppl 1</Volume>
                    <PubDate>
                        <Year>2015</Year>
                    </PubDate>
                </JournalIssue>
                <Title>Acta medico-historica adriatica : AMHA</Title>
                <ISOAbbreviation>Acta Med Hist Adriat</ISOAbbreviation>
            </Journal>
            ***<ArticleTitle>***The origin of the concept of neuropathic pain in Early Medieval Persia (9th - 12th century CE).</ArticleTitle>
            <Pagination>
                <MedlinePgn>9-22</MedlinePgn>
            </Pagination>
            <Abstract>
                ***<AbstractText>***Neuropathic pain is supposed to be a post-renaissance described medical entity. Although it is often believed that John Fothergill (1712-1780) provided the first description of this condition in 1773, a review of the medieval Persian medical writings will show the fact that neuropathic pain was a medieval-originated concept. &quot;Auojae Asab&quot; [Nerve-originated Pain[ was used as a medical term in medieval Persian medical literature for pain syndromes which etiologically originated from nerves. Physicians like Rhazes (d. 925 CE), Haly Abbas (d. 982 CE), Avicenna (d. 1037 CE), and Jorjani (d. 1137 CE) have discussed multiple aspects of nerve-originated pain including its classification, etiology, differentiating characteristics, different qualities, and pharmacologic and non-pharmacologic treatments. Recognizing medieval scholars' views on nerve-originated pain can lighten old historical origins of this concept.</AbstractText>
            </Abstract>
            <AuthorList CompleteYN="Y">
                <Author ValidYN="Y">
                    <LastName>Heydari</LastName>
                    <ForeName>Mojtaba</ForeName>
                    <Initials>M</Initials>
             .....
           ......
        .......
</PubmedArticleSet>

输出(PubTator)格式(在使用python解析XML之后)将具有以下结构中的以下标记的值:

    <PMID>|t|<ArticleTitle>
    <PMID>|a|<AbstractText>

ta在每个块中都是常数

主文件包含许多使用相同标记和相同结构的XML块。输出将把每个XML块更改为一个PubTator块。因此,输出文件的PubTator块将等于输入文件中XML块的数量。你知道吗

谢谢。你知道吗


Tags: 文件ofthexmlyearmedicalceprint

热门问题