Flattening XML data during deserialization

  • Thread starter Thread starter Robert Jacobson
  • Start date Start date
R

Robert Jacobson

Hi,

If I have an XML file that stores its data in a hierarchical relationship,
is there a way to automatically "flatten" this relationship when I
deserialize it (using the XmlSerializer) to a collection of objects?

For example, assume that I have an XML file that contains the following data
for lastnames/firstnames:

Anderson
Bob
Ann
Jones
Betty
Fred
Mark
Smith
Paul
Gina

I'd like to deserialize this file into a set of "Person" objects, with each
Person containing both a lastname and firstname (rather than separate
"LastName" and "FirstName" objects in a hierarchical relationship):

Anderson, Bob
Anderson, Ann
Jones, Betty
Jones, Fred
Jones, Mark
Smith, Paul
Smith, Gina

Is there any Framework way to do this automatically (perhaps by using an
attribute), or do I need to write custom deserialization code to do this?
Many thanks.
 
Deserialize and run through an XSLT stylesheet that gives you what you are
looking for. With XSLT, this exercise will be fairly easy and fast.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
It looks like that will do the trick. Thanks!

Cowboy (Gregory A. Beamer) said:
Deserialize and run through an XSLT stylesheet that gives you what you are
looking for. With XSLT, this exercise will be fairly easy and fast.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Back
Top