Thanks for your input. I removed the response.view and added the xml extension in the request:
https://localhost/testapp/api/icd10.xml?search=string and it worked. Is there any way to get an xml view without adding the xml extension? Le dimanche 12 juin 2016 02:54:43 UTC+2, Anthony a écrit : > > How are you calling that action? The content type won't be set to XML > unless you use a .xml extension in the request (or explicitly set the > content-type header yourself). > > Two additional observations: > > 1. You have specified generic.xml as the view, but your code builds an > XML string, so there would seem to be no point in passing anything to the > generic.xml view. > 2. Because your code returns a string, no view will be executed > anyway, as views are only executed when actions return a dictionary. > > Anthony > > On Saturday, June 11, 2016 at 5:25:38 PM UTC-4, Mamisoa Andriantafika > wrote: >> >> Hi, >> >> With this code: >> >> @request.restful() >> def icd10(): >> import libxml2 >> icd10_xml = libxml2.parseDoc(open( >> '/home/www-data/web2py/applications'+URL('static', >> 'icd10/icd10cm/Tabular.xml'),'r').read()) >> response.view = 'generic.xml' >> def GET(**vars): >> search_str = request.vars.search >> xpath_req = '//chapter/section/diag/desc[contains(text(),"'+ >> search_str+'")]' >> diags = icd10_xml.xpathEval(xpath_req) >> concat = '<?xml version="1.0" encoding="utf-8"?><main>' >> for diag in diags: >> diag_str = str(XML(diag)) >> concat = concat + diag_str >> concat = concat + '</main>' >> return concat >> return locals() >> >> I get an HTML view instead of XML. >> >> Why? >> >> Mike >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

