Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All,

Im having a problem serializing an xml document

My document is structured like this:
XML
<recentActivity>
  <add>
    <file>
      <displayName>Logon.aspx</displayName>
      <ref>https://........</ref>
      <size>336</size>
      <lastModified>2012-05-25T04:40:57.000-07:00</lastModified>
      <mediaType>application/octet-stream</mediaType>
      <presentOnServer>true</presentOnServer>
      <fileData>https://..........</fileData>
    </file>
  </add>
  <edit>
    <file>
      <displayName>somefile.suo</displayName>
      <ref>https://...........</ref>
      <size>83968</size>
      <lastModified>2012-05-25T04:34:51.000-07:00</lastModified>
      <mediaType>application/octet-stream</mediaType>
      <presentOnServer>true</presentOnServer>
      <fileData>https://...........</fileData>
    </file>
  </edit>
</recentActivity>


As you can see, the "file" elements parent can be either "add" or "edit"

Here are my class objects
VB
<XmlRoot("recentActivity")>
Public Class RecentActivities
    <XmlElement("edit"), XmlElement("add")> Public Property Items As ObjectModel.Collection(Of Activity)
End Class

Public Class Activity
    <"I need help here"> Public Property Action As String
    <XmlElement("file")> Public Property Details As FileDetails
End Class


In the code block above i need the "Action" property to be the name of the files parent element "add" or "edit"

How do i do it in one list? is it even possible?

i toyed with 2 lists, one for add and one for edit, but the output is in a specific order thats not always related to the lastmodified element of a file

Thanks in Advance
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900