Hi, Thomas, Thanks for your response, I changed to this url:
http://localhost:8080/xwikim/bin/get/Main/hellotest?outputSyntax=plain But I got responseXML containing this error: XML Parsing Error: no element found Location: http://localhost:8080/xwikim/bin/get/Main/hellotest?outputSyntax=plain Line Number 1, Column 1: then I changed to this velocity code: {{velocity output='false'}} $response.setContentType('application/xml') #set ($out = $response.getOutputStream()) $out.write("<?xml version='1.0' encoding='ISO-8859-1'?><test>test done</test>") $out.flush() ##$out.close() {{/velocity}} Still the same parsing error, any clue? Thanks Dave On Sat, Mar 24, 2012 at 4:38 AM, Thomas Mortagne <[email protected]>wrote: > On Sat, Mar 24, 2012 at 3:23 AM, du du <[email protected]> wrote: > > Hi, all, > > > > I followed this link: > > http://platform.xwiki.org/xwiki/bin/DevGuide/WritingComponents > > created a component which return xml data. > > Also I created a hellotest page inside the main space, and wrote the > > following velocity code: > > > > {{velocity output='false'}} > > $response.setContentType('application/xml') > > > > #set ($xmldata= $services.hello.getHelloXML()) > > $xmldata > > > > ##$context.setFinished(true) > > #set ($out = $response.getOutputStream()) > > $out.write($xmldata) > > $out.flush() > > > > {{/velocity}} > > > > I tested this code, I can get the xml data, now I use this ajax code to > > retrieve the xml data: > > > > var xmlhttp = GetXmlHttp(); > > if (xmlhttp) { > > xmlhttp.open("GET", url, true); > > xmlhttp.onreadystatechange = function () { > > if (xmlhttp.readyState == 4) { > > xmlResult = xmlhttp.responseText; > > ...... > > xmlhttp.send(null); > > } > > The url I used is: > > url = ' > > http://localhost:8080/xwikim/bin/view/Main/hellotest?outputSyntax=plain' > > > > when I debug with firefox to see the data inside xmlhttp either > > responseText or response, they were all a html document for the hellotest > > with the tags like body, div, etc, it is basically helltest.html file if > > you view the source code of this html page. I tried to change the output > to > > true, the result is the same. > > That's because with this URL you get UI around your content (whatever > is the syntax of your content), for this kind of use case you should > use /get/ action instead of /view/. > > > > > Question: how can I get the xml data? where am I wrong? > > > > Thanks very much in advance. > > > > Dave > > _______________________________________________ > > users mailing list > > [email protected] > > http://lists.xwiki.org/mailman/listinfo/users > > > > -- > Thomas Mortagne > _______________________________________________ > users mailing list > [email protected] > http://lists.xwiki.org/mailman/listinfo/users > _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

