I'd like some guidance in returning an XML doc from a controller to a view. In my view, I'd like to traverse the XML doc using JQuery. There are plenty of online examples using JQuery for this use.
I have a PortfolioList() Controller below, which right now just returns the view, but I would like to figure out how to RETURN THE XML RESPONSE. You'll noticed below that I'm writing the XML response to a local file just for testing purposes...
Do I need to cleanly create a model for this ?
public ActionResult PortfolioList()
{
XmlDocument xmlResponse = new XmlDocument();
XmlDocument xmlRequest = new XmlDocument();
bool rzInitialized = nitializeRz();
if (rzInitialized == false)
{
ViewBag.Message = "Rz Init has failed. Check if Rz is running";
return View();
}
bool rzConnected = ConnectToRz();
ViewBag.Message = "Here you may view a list of portfolios and exposures.";
// Build Portfolio Select request here !
RequestBuilder rzRequest = new RequestBuilder();
// REQUEST FOR PORTFOLIOS !
string portfoliosRequest = rzRequest.PortfoliosRequest("Portfolios");
string **portfoliosResponse** = RzClient.sendRequest(portfoliosRequest, false);
// DEBUG REQUESTS !!
if (Debugflag)
{
rzRequest.DebugOutput("portfolios", portfoliosRequest, portfoliosResponse);
}
DisconnectFromRz();
return View("PortfolioList");
}
You can do it as follows.
public ActionResult PortfolioList()
{
//Your code
....
return this.Content(yourXml, "text/xml");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With