?
Solved

XmlElement

Posted on 2006-07-19
2
Medium Priority
?
1,187 Views
Last Modified: 2012-06-27
public class NewSTBLog
      {
            [XmlElement(ElementName = "LogBatch")]
            public NewLogBatch STBLogBatch;

            [XmlElement(typeof(LogRecord))]      
            public object[] LogRecords;
      }  


      //Structure of the Batch
      public class NewLogBatch
      {
            [XmlIgnore()]
            public char MSFTVersion;

            [XmlIgnore()]
            public char DeviceSerialNumLen;
            public string DeviceSerialNum;
            public char BatchNumber;
            public string LogInitTime;

            [XmlIgnore()]
            public char AccessPointIdLen;  
            public string AccessPointId;                        
            public string EndLogTime;

            [XmlIgnore()]
            public short NumRecordsStored;      
      }               

          
      //Structure of the Log Records
      public class NewLogRecord
      {
            [XmlIgnore()]
            public int LogType;             
                    
            [XmlElement(typeof(ADClicks)), XmlElement(typeof(ADDisplays)), XmlElement(typeof(NewApplicationLogs))]      
            [XmlElement(typeof(AppPermissionViolations)), XmlElement(typeof(BoxPower)), XmlElement(typeof(DVR))]
            [XmlElement(typeof(GamePlay)), XmlElement(typeof(MenuClick)), XmlElement(typeof(MenuView)), XmlElement(typeof(TVView))]  
            public object oActivityLogs;  
      }                                    

At one point XmlElement(ElementName=LogBatch) used and else where typeof is used in XmlElement ... what does that mean ? cant i use both element name and type of in one XmlElement attribute ? whats the difference in the use of the 2 ?

Please explain !!!
0
Comment
Question by:deersuper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
anyoneis earned 1000 total points
ID: 17143391
If you don't use "ElementName=xxx", then the field name will be used. In the cases where you are using typeof, you are essentially describing a collection of possible types that can be found in oActivityLogs.

Here is a pretty good basic example: http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlelementattribute.type.aspx

David
0
 
LVL 13

Expert Comment

by:devsolns
ID: 17145460
Look at is IXmlSerializable.  Its official for use in .NET 2.0 and it leads to a much better class design than anything attribute based.  IXmlSerializable will allow public/protected/private members to be serialized.


-gp
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question