tags:

views:

63

answers:

2

How build ASP.NET MVC View page from XML file?

<?xml version="1.0" encoding="utf-8" ?> 
- <TecajnaLista>
- <Valuta>
<Drzava>Australija</Drzava> 
<Oznaka>AUD</Oznaka> 
<Sfr>036</Sfr> 
<Jedinica>1</Jedinica> 
<Iznos>4.385692</Iznos> 
</Valuta>
- <Valuta>
<Drzava>Japan</Drzava> 
<Oznaka>YPY</Oznaka> 
<Sfr>392</Sfr> 
<Jedinica>100</Jedinica> 
<Iznos>4.704524</Iznos> 
</Valuta>
- <Valuta>
<Drzava>Velika Britanija</Drzava> 
<Oznaka>GBP</Oznaka> 
<Sfr>826</Sfr> 
<Jedinica>1</Jedinica> 
<Iznos>10.960638</Iznos> 
</Valuta>
- <Valuta>
<Drzava>USA</Drzava> 
<Oznaka>USD</Oznaka> 
<Sfr>840</Sfr> 
<Jedinica>1</Jedinica> 
<Iznos>5.570351</Iznos> 
</Valuta>
- <Valuta>
<Drzava>EU</Drzava> 
<Oznaka>EUR</Oznaka> 
<Sfr>978</Sfr> 
<Jedinica>1</Jedinica> 
<Iznos>7.357876</Iznos> 
</Valuta>
</TecajnaLista>

I have build data table from this XML

A: 

In the controller you can load an XmlDocument from the xml file; next you can pass the XmlNode as to a strongly typed View. Once that is done, you can use all normal XmlNode methods to compose your view.

Thomas
+1  A: 

Checkout the XmlResult type in MVC Contrib.

KMan