In the past, I've saveXML()'ed the XML string to a template variable,
and echoed it from the template, but after examining the xmlrpc stuff in
the sample app, I don't think this is the best way to do it.

What I've come up with, I hope is correct. As per my previous method, I
still have an xml output type defined in output_types.xml:

<output_type name="xml">
   <parameters>
     <parameter name="http_headers">
       <parameter name="Content-Type">text/xml; charset=UTF-8</parameter>
     </parameter>
   </parameters>
</output_type>

Note there is no renderers or layouts block for this output type.

I ensure that routing knows this request will _always_ serve xml:

<route pattern="^/sysinfo$" module="%actions.default_module%"
action="SysInfo" output_type="xml" />

Then in my view, I have an executeXml():

public function executeXml(AgaviRequestDataHolder $rd)
{
         $xmlDoc = new DomDocument('1.0');

         $root = $xmlDoc->createElement('myxml');
         $xmlDoc->appendChild($root);

         $foo = $xmlDoc->createElement('blah', 'foofoo');
         $root->appendChild($foo);

         $xmlDoc->formatOutput = true;
         $this->getResponse()->setContent($xmlDoc->saveXML());
}

which directly injects the xml string into the response content. No
template setup.

Is this the most elegant way of going about it?


_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to