Krishna
Krishna

Reputation: 1474

How to get an xml response in Zend controller and pass it to zend view (mhtml page) and parse it to render it

I get a response in xml format from a url, I wrote that code in a controller. I am able to catch the whole xml in the form of a string. Now i need to pass that xmlString from zend controller to zend view. How to do that. And then parse the xml string in zend view and render it in a tabular format.

Upvotes: 0

Views: 351

Answers (2)

dinopmi
dinopmi

Reputation: 2673

You can usually assign values to the view from the controller like that:

$this->view->field = $value;

Each action is usually associated to a view script (a template), for instance action.phtml. You can output the value of the fields you have set in the action, something like

<?php echo $this->field; ?>

wherever you need in the script.

You can have a look at the view scripts documentation for further information.

Upvotes: 0

prodigitalson
prodigitalson

Reputation: 60413

To piggy back on what dinopmi said you probably dont want to parse the XML directly in the view. Instead you want to handle this in a custom View Helper or directly in the controller before passing it to the view.

The View Helper solution is more complex but its more reusable and its probably the more correct of the two solutions. You can read more about creating your own View Helpers in the documentation.

Upvotes: 0

Related Questions