Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / October 2003

Tip: Looking for answers? Try searching our database.

Flattening XML data during deserialization

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert Jacobson - 21 Oct 2003 20:10 GMT
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.
Cowboy \(Gregory A. Beamer\) - 21 Oct 2003 20:58 GMT
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.

Signature

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

**********************************************************************
Think Outside the Box!
**********************************************************************

> Hi,
>
[quoted text clipped - 31 lines]
> attribute), or do I need to write custom deserialization code to do this?
> Many thanks.
Robert Jacobson - 21 Oct 2003 21:23 GMT
It looks like that will do the trick.  Thanks!

"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@comcast.netNoSpamM> wrote in
message news:uqb4c5AmDHA.3320@tk2msftngp13.phx.gbl...
> 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.
[quoted text clipped - 36 lines]
> > attribute), or do I need to write custom deserialization code to do this?
> > Many thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.