Skip to content

Commit

Permalink
#135 Use doi from ELocationID insted of ArticleIdList
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-herrmann committed Apr 21, 2024
1 parent 15c477a commit 9b2e3f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pubmed_parser/pubmed_web_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ def parse_pubmed_web_tree(tree):
keywords = ""

doi = ""
article_ids = tree.xpath("//articleidlist//articleid")
article_ids = tree.xpath("//elocationid")
if len(article_ids) >= 1:
for article_id in article_ids:
if article_id.attrib.get("idtype") == "doi":
if article_id.attrib.get("eidtype") == "doi":
doi = article_id.text

language = tree.xpath("//language")
Expand Down
5 changes: 5 additions & 0 deletions tests/test_pubmed_web_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ def test_pubmed_web_parser_save_xml():
pubmed_dict = pp.parse_xml_web(random_id, save_xml=True)

assert "xml" in pubmed_dict

def test_doi():
"""Test the correct parsing of the doi."""
pubmed_dict = pp.parse_xml_web("32145645", save_xml=False)
assert pubmed_dict['doi'] == "10.1016/j.ejmech.2020.112186"

0 comments on commit 9b2e3f7

Please sign in to comment.