i have repository attempts load xml document class. seems go alright until attempt access descendants elements in map config section.
this structure of xml file:
<apps> <item> <id>1</id> <engineversion>1.0</engineversion> <mapconfig> <minzoom>3</minzoom> <maxzoom>18</maxzoom> <startcenterlat>-28</startcenterlat> <startcenterlng>135</startcenterlng> <startzoom>3</startzoom> </mapconfig> </item> </apps>
and repository method on controller:
public apprepository() { allapps = new list<app>(); appdata = xdocument.load(httpcontext.current.server.mappath("~/app_data/apps.xml")); var apps = app in appdata.descendants("item") select new app( (int)app.element("id"), (float)app.element("engineversion"), new mapconfig ( (int)app.descendants("mapconfig").descendants("minzoom").firstordefault(), (int)app.descendants("mapconfig").descendants("maxzoom").firstordefault(), (float)app.descendants("mapconfig").descendants("startcenterlat").firstordefault(), (float)app.descendants("mapconfig").descendants("startcenterlng").firstordefault(), (int)app.descendants("mapconfig").descendants("startzoom").firstordefault() ) ); allapps.addrange(apps.tolist<app>()); }
this seems result in id , engine version values correctly being read app object mapconfig object seems have 0 set value of elements.
can see doing wrong?
Comments
Post a Comment