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.
Question: how can I get the xml data? where am I wrong?
Thanks very much in advance.
Dave