473,398 Members | 2,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Deserializing an entire XML structure to class instances

4
I have an XML fil that looks like this:

Expand|Select|Wrap|Line Numbers
  1. <Environment>
  2.     <AreaOfInterest>
  3.       <Name>ScenarioMap</Name>
  4.       <UpperRight>
  5.         <GDC>
  6.           <Latitude>-179</Latitude>
  7.           <Longitude>-179</Longitude>
  8.           <ElevationAGL>0</ElevationAGL>
  9.         </GDC>
  10.       </UpperRight>
  11.       <LowerLeft>
  12.         <GDC>
  13.           <Latitude>180</Latitude>
  14.           <Longitude>180</Longitude>
  15.           <ElevationAGL>0</ElevationAGL>
  16.         </GDC>
  17.       </LowerLeft>
  18.     </AreaOfInterest>
  19.   </Environment>
  20.  
Currently, I'm deserializing the code as follows;
Expand|Select|Wrap|Line Numbers
  1.                 XmlNode xmlnode = doc.SelectSingleNode("//Environment");
  2.                 XmlSerializer ser = new XmlSerializer(typeof(Environment));
  3.                 XmlNodeReader reader = new XmlNodeReader(xmlnode);
  4.                 Environment en = (Environment)ser.Deserialize(reader);
  5.  
(And it goes on for each node...)

So I'm deserializing each node by themselves. However, I'd like to deserialize the entire XML without having to hard code which class name and which node I want to deserialize. How can I accomplish this? Also, the XML might (it might not) have multiple occurances of a similar named node, as seen above.
Apr 3 '08 #1
0 960

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Kenneth Baltrinic | last post by:
I am getting the following error when deserializing an object that has a couple of dozen dependant objects in its object graph. Anyone who can suggest where I might begin to look to resolve problem...
1
by: Thomas | last post by:
Hi, I implemented a composite pattern which should be serializable to xml. After spending some time in the newsgroups, i finally managed serializing, even with utf-8 instead of utf-16, which...
4
by: Wayne Wengert | last post by:
Using VB.NET I want to read in an XML file that has an array of objects and then step through the resulting array in code. I build a class to define the structure and I am running code to read in...
0
by: Greg Merideth | last post by:
I've got a web method returning 42 values that I need/would like to put into a class that has the same layout/structure. The dataset.merge works fine to retrieve the data from the web method but...
6
by: JSheble | last post by:
Are there any reasons why I shouldn't or couldn't use a structure as a property in a class? Specifically since structures are value types and objects are reference types? I have a Shipping...
6
by: zacks | last post by:
I recently wrote a VB.NET application using VS2005. I needed to be able to build linked lists in memory of items that were represented by a group of variables. For example, Friend Structure foo...
1
by: =?Utf-8?B?SmVyZW15X0I=?= | last post by:
I am working on an order entry program and have a question related to deserializing nodes with nested elements. The purchase order contains multiple line items which I select using an...
6
by: olympus_mons | last post by:
Hi, I generated C# classes from some complex XMLSchemas usind xsd.exe. The result is that I get a class hierarchy that is quite deep (well for me 8 levels are deep). What I'm curiuos about is,...
13
by: Rafe | last post by:
Hi, I am in a situation where I feel I am being forced to abandon a clean module structure in favor of a large single module. If anyone can save my sanity here I would be forever grateful. My...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.