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
Solved

XmlElement

Posted on 2006-07-19
2
1,173 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 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