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 _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs

