[Biopython] Pubmeddata XML parsing with Entrez .fetch and .read
Michiel de Hoon
mjldehoon at yahoo.com
Sun Jul 18 09:59:41 EDT 2010
--- On Sun, 7/18/10, Peter <biopython at maubp.freeserve.co.uk> wrote:
> I've not played with the code yet to see what you mean
> about the tag attribute.
Here's an example:
<eInfoResult>
<DbList>
<DbName>pubmed</DbName>
<DbName>protein</DbName>
<DbName>nucleotide</DbName>
<DbName>nuccore</DbName>
<DbName>nucgss</DbName>
....
>>> record['DbList'][0]
'pubmed'
>>> record['DbList'][0].tag
u'DbName'
>>> record['DbList'][0].attributes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'StringElement' object has no attribute 'attributes'
>>>
So currently record['DbList'] is a list of StringElements (actually, a ListElement of StringElements) where the XML tag name is stored in a .tag attribute. If we don't store the .tag attribute, then record['DbList'] would become a list of plain strings.
--Michiel.
More information about the Biopython
mailing list