Reputation: 847
I am building a MVC application in which i am consuming a webservice in my contorller which conntects to a webservice MyWebService. MyWebService has a webmethod GetProjects which takes two parameters. Return type of GetProjects is XmlDocument
Following is the cpde
public ActionResult Index()
{
MyWebService service = new MyWebService();
XmlNode xmlNode = service.GetProjects("12345", "54321");
StringWriter stringWriter = new StringWriter();
XmlTextWriter xmTextWriter = new XmlTextWriter(stringWriter);
xmlNode.
return Content(xmlNode, "text/xml")
};
Above program is running good.
I want to show the XmlDocument returned by controller in view.
In short how to show a XML document in view returned by Contoller
Upvotes: 1
Views: 924
Reputation: 555
You can try ViewData [xmldata] = xmlNode.OuterXml;
and in your view you can use ViewData[xmlData]
.
Full code is as folows:
public ActionResult Index()
{
MyWebService service = new MyWebService();
XmlNode xmlNode = service.GetProjects("12345", "54321");
ViewData [xmldata] = xmlNode.OuterXml
return view();
}
Upvotes: 1