Use XMLWriter to generate response

Gets rid of manual XML generation.
This commit is contained in:
Lukas Reschke 2015-11-30 15:40:10 +01:00
parent a94819f4a4
commit 574f9b1e3f
1 changed files with 29 additions and 18 deletions

View File

@ -27,22 +27,33 @@ require_once '../lib/base.php';
header('Content-type: application/xml'); header('Content-type: application/xml');
$url=OCP\Util::getServerProtocol().'://'.substr(OCP\Util::getServerHost().OCP\Util::getRequestUri(), 0, -17).'ocs/v1.php/'; $request = \OC::$server->getRequest();
echo(' $url = $request->getServerProtocol() . '://' . substr($request->getServerHost() . $request->getRequestUri(), 0, -17).'ocs/v1.php/';
<providers>
<provider> $writer = new XMLWriter();
<id>ownCloud</id> $writer->openURI('php://output');
<location>'.$url.'</location> $writer->startDocument('1.0','UTF-8');
<name>ownCloud</name> $writer->setIndent(4);
<icon></icon> $writer->startElement('providers');
<termsofuse></termsofuse> $writer->startElement('provider');
<register></register> $writer->writeElement('id', 'ownCloud');
<services> $writer->writeElement('location', $url);
<config ocsversion="1.7" /> $writer->writeElement('name', 'ownCloud');
<activity ocsversion="1.7" /> $writer->writeElement('icon', '');
<cloud ocsversion="1.7" /> $writer->writeElement('termsofuse', '');
</services> $writer->writeElement('register', '');
</provider> $writer->startElement('services');
</providers> $writer->startElement('config');
'); $writer->writeAttribute('ocsversion', '1.7');
$writer->endElement();
$writer->startElement('activity');
$writer->writeAttribute('ocsversion', '1.7');
$writer->endElement();
$writer->startElement('cloud');
$writer->writeAttribute('ocsversion', '1.7');
$writer->endElement();
$writer->endElement();
$writer->endElement();
$writer->endDocument();
$writer->flush();