gijswobben / pymed

PyMed is a Python library that provides access to PubMed.
MIT License
191 stars 111 forks source link

Access to Affiliation in XML data #16

Closed yuanchueh closed 5 years ago

yuanchueh commented 5 years ago

Is your feature request related to a problem? Please describe. It's important to me to see the affiliation information associated with an author if applicable. I can't see where this is being extracted from the returned XML.

Describe the solution you'd like Ideally, this would be an additional return in the form of .affiliation.

Describe alternatives you've considered

I created a "hack" by editing article.py def _extractAuthors(self: object, xml_element: TypeVar("Element")) -> list: return [ { "lastname": getContent(author, ".//LastName", None), "firstname": getContent(author, ".//ForeName", None), "initials": getContent(author, ".//Initials", None), "affiliation": getContent(author, ".//AffiliationInfo/Affiliation", None), } for author in xml_element.findall(".//Author") ]

gijswobben commented 5 years ago

That's not a "hack" but a fix ;). I've updated the code.

Thanks!