I don't know which programming language you're using (python maybe ? I don't know python) but this could indicate that your object has no method called xml. Maybe whatever module you're using is not capable of handling xml. The solution is to deal with the xml yourself, maybe with the help of another module.
This looks now more like a programming question and not a bioinformatics one. You may have better luck asking on StackOverflow.
Alternatively, explain what you're trying to do, i.e. what bioinformatics problem you're trying to solve. There may already be a solution.
So far, eUtils only allows retmode='json' for eSearch queries.
with request.urlopen(search_url) as response:
content = response.read()
data = json.loads(content)
web = data['esearchresult']['webenv']
key = data['esearchresult']['querykey']
count = int(data['esearchresult']['count'])
ids = data['esearchresult']['idlist']
When you are planning to eFetch 'pubmed' data you have three options for retmode (asn.1, text, xml). Within the text category you can select 3 different kinds of rettypes (medline, uilist, abstract) of which only 'medline' will get you all the data of the publication. Both 'asn.1' and 'xml' retmodes do not have associated rettypes, so you can ignore setting that field in those scenarios [1].
with request.urlopen(fetch_url) as response:
content = response.read()
soup = BeautifulSoup(content, 'html.parser')
You will be getting real json output for your eSearch results, but HTML/XML for the eFetch call. There currently is no way to get eFetch results in json format. Hopefully NCBI adds this functionality to their other eUtils tools soon!
I don't understand the issue here. If you want xml output from NCBI, just use retmode=xml in the url.
Already did this and it returns an error
What does return an error ? What's the error message ?
I changed the following:
I got this error:
AttributeError Traceback (most recent call last)
<ipython-input-8-262417e4aa63> in <module>()
db=pubmed&mindate=2010/01/01&maxdate=2016/12/31&usehistory=y&retmode=xml"
----> 3 search_data = search_r.xml()
4 webenv = search_data["esearchresult"]['webenv']
AttributeError: 'Response' object has no attribute 'xml'
I don't know which programming language you're using (python maybe ? I don't know python) but this could indicate that your object has no method called xml. Maybe whatever module you're using is not capable of handling xml. The solution is to deal with the xml yourself, maybe with the help of another module. This looks now more like a programming question and not a bioinformatics one. You may have better luck asking on StackOverflow. Alternatively, explain what you're trying to do, i.e. what bioinformatics problem you're trying to solve. There may already be a solution.