Advertisement
dragonbe

parse xml

Feb 24th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1.     public function lowercaseAction()
  2.     {  
  3.         $format = $this->getRequest()->getParam('format', 'xml');
  4.         $word = $this->getRequest()->getParam('word', 'Hello');
  5.  
  6.         switch ($format) {
  7.             case 'json':
  8.                 $this->_helper->viewRenderer()->setNoRender(true);
  9.                 $this->_helper->json(array ('word' => $word));
  10.                 break;
  11.             case 'xml':
  12.             default:
  13.                 $this->getResponse()->setHeader('Content-type', 'text/xml');
  14.                 $xmlstr = '<word>' . $word . '</word>';
  15.                 $xml = new SimpleXMLElement($xmlstr);
  16.                 $this->view->xml = $xml->asXML();
  17.                 break;
  18.         }  
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement