python对XML数据进行处理,提取标签内容并形成一一对应的关系,输出结果在CSV文件里,给出代码
使用python来实现
数据格式:
<dblp>
<article mdate="2017-05-28" key="journals/acta/Saxena96">
<author>Sanjeev Saxena</author>
<title>Parallel Integer Sorting and Simulation Amongst CRCW Models.</title>
<pages>607-619</pages>
<year>1996</year>
<volume>33</volume>
<journal>Acta Inf.</journal>
<number>7</number>
<url>db/journals/acta/acta33.html#Saxena96</url>
<ee>https://doi.org/10.1007/BF03036466</ee>
</article>
<article mdate="2017-05-28" key="journals/acta/GoodmanS83">
<author>Nathan Goodman</author>
<author>Oded Shmueli</author>
<title>NP-complete Problems Simplified on Tree Schemas.</title>
<pages>171-178</pages>
<year>1983</year>
<volume>20</volume>
<journal>Acta Inf.</journal>
<url>db/journals/acta/acta20.html#GoodmanS83</url>
<ee>https://doi.org/10.1007/BF00289414</ee>
</article>
</dblp>
想要提取每个作者标签<author>内容和期刊<journal>标签内容,输出成一一对应的关系数据,取得结果类似如下:
Sanjeev Saxena,Acta Inf
Nathan Goodman,Acta Inf
Oded Shmueli,Acta Inf
第一列为作者,第二列为所投期刊,取得的结果输出到CSV文件。
给出python代码,谢谢