<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>C#</title><link>http://forums.asp.net/37.aspx</link><description>Discussions/Questions about the C# language. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=13&amp;c=23" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Error reflecting type when trying to serialize</title><link>http://forums.asp.net/thread/3269360.aspx</link><pubDate>Wed, 01 Jul 2009 16:11:29 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3269360</guid><dc:creator>Dangermouse</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3269360.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3269360</wfw:commentRss><description>&lt;p&gt;Hi, thanks for the response.&lt;/p&gt;
&lt;p&gt;Unfortunately the way the XML is, I have to create two separate tags (plyrdets) but they have different contents. I understand that this is strange and probably a bad XML design however I need to create a serializable class to hold this information.&lt;/p&gt;
&lt;p&gt;I can add an attribute to the tag to distinguish between them. Do you know how I can serialize this XML design (original post)&amp;nbsp;into a class please?&lt;/p&gt;</description></item><item><title>Re: Error reflecting type when trying to serialize</title><link>http://forums.asp.net/thread/3269338.aspx</link><pubDate>Wed, 01 Jul 2009 16:01:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3269338</guid><dc:creator>richiej</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3269338.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3269338</wfw:commentRss><description>&lt;p&gt;The&amp;nbsp;answer lies in how you defined your class! &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;.. you&amp;nbsp;have&amp;nbsp;&amp;quot;PlyrDetails&amp;quot; and &amp;quot;PlyrDetails2&amp;quot; - despite having the same xmelement name because they are different classes you will have 2 different elements in your&amp;nbsp;xml&amp;nbsp;document.&lt;/p&gt;
&lt;p&gt;Do you need&amp;nbsp;2 different&amp;nbsp;player details classes or can you not have one?&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Error reflecting type when trying to serialize</title><link>http://forums.asp.net/thread/3269122.aspx</link><pubDate>Wed, 01 Jul 2009 14:09:30 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3269122</guid><dc:creator>Dangermouse</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3269122.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3269122</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="c-sharp" name="code"&gt;[Serializable]
    [XmlRoot(ElementName = &amp;quot;plyr&amp;quot;)] 
    public class Player
    {
        private string _club;
        private PlyrDetails _plyrDetails;
        private PlyrDetails2 _plyrDetails2;

        [XmlElement(ElementName = &amp;quot;club&amp;quot;)]
        public string Club
        {
            get { return _club; }
            set { _club = value; }
        }

        [XmlElement(ElementName = &amp;quot;plyrdets&amp;quot;)]
        public PlyrDetails PlyrDetails
        {
            get { return _plyrDetails; }
            set { _plyrDetails = value; }
        }

        [XmlElement(ElementName = &amp;quot;plyrdets&amp;quot;)]
        public PlyrDetails2 PlyrDetails2
        {
            get { return _plyrDetails2; }
            set { _plyrDetails2 = value; }
        }
    }

    public class PlyrDetails
    {
        private string _firstName;
        private string _lastName;

        [XmlElement(ElementName = &amp;quot;first&amp;quot;)]
        public string FirstName
        {
            get { return _firstName; }
            set { _firstName = value; }
        }

        [XmlElement(ElementName = &amp;quot;last&amp;quot;)]
        public string LastName
        {
            get { return _lastName; }
            set { _lastName = value; }
        }
    }

    public class PlyrDetails2
    {
        private string _dob;
        private string _position;

        [XmlElement(ElementName = &amp;quot;dob&amp;quot;)]
        public string Dob
        {
            get { return _dob; }
            set { _dob = value; }
        }

        [XmlElement(ElementName = &amp;quot;position&amp;quot;)]
        public string Position
        {
            get { return _position; }
            set { _position = value; }
        }
    }&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Error reflecting type when trying to serialize</title><link>http://forums.asp.net/thread/3268811.aspx</link><pubDate>Wed, 01 Jul 2009 12:07:17 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3268811</guid><dc:creator>richiej</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3268811.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3268811</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Can you post your code for your class please, just wanted to see how you&amp;#39;ve defined your class&lt;/p&gt;</description></item><item><title>Error reflecting type when trying to serialize</title><link>http://forums.asp.net/thread/3268281.aspx</link><pubDate>Wed, 01 Jul 2009 08:24:40 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3268281</guid><dc:creator>Dangermouse</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3268281.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3268281</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hi, when I try and run this statement:&lt;/p&gt;
&lt;p style="PADDING-LEFT:30px;"&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#2b91af;FONT-FAMILY:;"&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#2b91af;FONT-FAMILY:;"&gt;XmlSerializer&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="PADDING-LEFT:30px;"&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;s = &lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt; &lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#2b91af;FONT-FAMILY:;"&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#2b91af;FONT-FAMILY:;"&gt;XmlSerializer&lt;/span&gt;&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;(&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#0000ff;FONT-FAMILY:;"&gt;typeof&lt;/span&gt;&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;(PlayerXMLClass.&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#2b91af;FONT-FAMILY:;"&gt;&lt;span class="" style="FONT-SIZE:x-small;COLOR:#2b91af;FONT-FAMILY:;"&gt;Player&lt;/span&gt;&lt;/span&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="" style="FONT-SIZE:x-small;FONT-FAMILY:;"&gt;The XML is unusual in its structure:&lt;/span&gt;&lt;/p&gt;&lt;pre class="xhtml" name="code"&gt;&amp;lt;?xml version=\&amp;quot;1.0\&amp;quot; encoding=\&amp;quot;utf-8\&amp;quot;?&amp;gt;
&amp;lt;plyr xmlns:xsi=\&amp;quot;http://www.w3.org/2001/XMLSchema-instance\&amp;quot; xmlns:xsd=\&amp;quot;http://www.w3.org/2001/XMLSchema\&amp;quot;&amp;gt;
 &amp;lt;club&amp;gt;Arsenal&amp;lt;/club&amp;gt;
    &amp;lt;plyrdets&amp;gt;
       &amp;lt;first&amp;gt;Cesc&amp;lt;/first&amp;gt;
       &amp;lt;last&amp;gt;Fab&amp;lt;/last&amp;gt;
    &amp;lt;/plyrdets&amp;gt;
    &amp;lt;plyrdets&amp;gt;
       &amp;lt;dob&amp;gt;12/12/1988&amp;lt;/dob&amp;gt;
       &amp;lt;position&amp;gt;midfielder&amp;lt;/position&amp;gt;
    &amp;lt;/plyrdets&amp;gt;
&amp;lt;/plyr&amp;gt;&lt;/pre&gt;
&lt;p&gt;The inner exception is:&lt;/p&gt;
&lt;p&gt;The XML element &amp;#39;plyrdets&amp;#39; from namespace&amp;nbsp;is already present in the current scope. Use XML attributes to specify another XML name or namespace for the element.&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>