Solved

XmlElement

Posted on 2006-07-19
2
1,158 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
2 Comments
 
LVL 11

Accepted Solution

by:
anyoneis earned 250 total points
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now