Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XmlElement

Posted on 2006-07-19
2
Medium Priority
?
1,197 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

636 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