2

I am working on a project that requires that I render XML data (that would be my model). Its basically going to be represented in a row - column format similar to your standard database representation. Except you should be able to click on a row and from there perform some basic data entry. I initially thought about using Json data and Jgrid to do this, but It seems like it may be more trouble than it is worth. From conversations with my co-workers, it seems as though it is possible to send xml from a controller straight to the view. Since XML is just a string, I guess that wouldn't be to hard. I am just a little unsure about how to get this done. So I guess I mentioned all that to ask, how can you render XML data in a view that you get from a controller. What is best practice in a situation like this? What is the best way to send XML over from a controller to a view? What is the best way to render this view? Is there a way that I can make a row of that xml data "clickable"? Should I just byte the bullet and try and figure out jqGrid?

Thanks, Derek

SoftwareSavant
  • 9,467
  • 27
  • 121
  • 195
  • It seems to me that you want to do something without really learning what's behind the scenes. MVC is hard to understand at the beginning but it allows you to do great things. And remember that you can close question answered with the checkbox. That's the way SO works. – LeftyX Jun 03 '11 at 13:29

1 Answers1

1

Your controller should return a model to your view.
It's easier to manage and you don't have to parse XML. It's all explained here and here

Watch these tutorials (Plurasight) if you have time.

LeftyX
  • 35,328
  • 21
  • 132
  • 193
  • Thanks. I will definitely read those articles and watch that video. Thanks. – SoftwareSavant Jun 03 '11 at 18:03
  • I know that I need to throw a controller to my view... But the thing is that data will be represented in this application as XML... The data will be pulled from a database, but I am getting it from a wcf webservice and it will be returned as an xml file. So I need to render that data from the xml file. I know how to set up a connection string and so forth for a database, but how would I go about that for an xml file? More research is required I suppose. – SoftwareSavant Jun 06 '11 at 12:10
  • Quick question, is there like a standard or best practice for taking an xml file and putting data into the model classes that I pass to the controller? Or will I have to use the standard xml reader and so forth to get that data into there. I have an XSD that I used to create my model classes, Now I have the models, but I need to place data into those models so I have something in the views. Any ideas? Thanks. – SoftwareSavant Jun 06 '11 at 12:47
  • user729820: You didn't close my previous answer, though. Do you know how SO works? – LeftyX Jun 06 '11 at 21:14
  • @user729820: I don't quite understand what you mean.If you have an XSD file you can create a class from that. and you can populate your class with the XML data deserializing it. Once you've got your model with data you can simply pass it to your view like this: return View(myModel); your view will be a typed view. It's explained very well here: http://stephenwalther.com/blog/archive/2009/04/13/asp.net-mvc-tip-50-ndash-create-view-models.aspx – LeftyX Jun 06 '11 at 21:19