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 2005

Tip: Looking for answers? Try searching our database.

deserialize IEnumerable with anyType tags

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Achim Domma (SyynX Solutions GmbH) - 26 Oct 2005 20:34 GMT
Hi,

I have a data structure which is serialzied into an xml like this:

<?xml version="1.0" encoding="utf-8"?>
<Storage xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Frames>
    <Frame Index="0">
      <Tags>
        <anyType xsi:type="ProjectInfo">
          <ProjectType>MediaTags.Projects.FACS</ProjectType>
          <MediaFile>C:\develop\JustForFun\Dyade07divx.avi</MediaFile>
        </anyType>
      </Tags>
    </Frame>
    <Frame Index="98">
      <Tags>
        <anyType xsi:type="FacsTag">
          <id>7</id>
        </anyType>
      </Tags>
    </Frame>
  </Frames>
</Storage>

If I try to deserialize this structure, everything works fine up to the
level of Tags. Tags is a class, which implements IEnumerable and the
required Add(object o) method.

But Add is not called with instances of ProjectInfo and FacsTag. It's
called with arrays of objects. The first entry is the xsi:type Attribute
followed by the child nodes of the anyType tag.

Is that correct behavior? I would have expected that the ProjectInfo and
FacsTag objects are deserialzied too. Is there something I have to do to
enable this functionality?

regards,
Achim
Achim Domma (SyynX Solutions GmbH) - 29 Oct 2005 17:21 GMT
> I have a data structure which is serialzied into an xml like this:
[...]
> But Add is not called with instances of ProjectInfo and FacsTag. It's
> called with arrays of objects. The first entry is the xsi:type Attribute
> followed by the child nodes of the anyType tag.

Just for the records, answering my own question:

The relevant data types were not known to the deserializer. I wondered
on how to tell the deserialzier about them, because you can pass types
to the Serialize function, but not to Deserialze. The solution is to
pass the types to the ctor of the serialzizer.

The following article was very helpfull in figuring out how
serializing/deserializing works:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/t
rblshtxsd.asp


regards,
Achim

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.