Click here to Skip to main content
15,886,110 members
Home / Discussions / C#
   

C#

 
QuestionCoding help Pin
Member 1139217221-Jan-15 7:04
Member 1139217221-Jan-15 7:04 
AnswerRe: Coding help Pin
Wendelius21-Jan-15 7:19
mentorWendelius21-Jan-15 7:19 
GeneralRe: Coding help Pin
Member 1139217221-Jan-15 7:43
Member 1139217221-Jan-15 7:43 
GeneralRe: Coding help Pin
Pete O'Hanlon21-Jan-15 9:06
mvePete O'Hanlon21-Jan-15 9:06 
QuestionDeserialize Parts of an XML Pin
Antonio Cambule20-Jan-15 22:32
Antonio Cambule20-Jan-15 22:32 
AnswerRe: Deserialize Parts of an XML Pin
Daniel Pfeffer20-Jan-15 22:55
professionalDaniel Pfeffer20-Jan-15 22:55 
GeneralRe: Deserialize Parts of an XML Pin
Antonio Cambule20-Jan-15 23:13
Antonio Cambule20-Jan-15 23:13 
GeneralRe: Deserialize Parts of an XML Pin
Daniel Pfeffer21-Jan-15 0:40
professionalDaniel Pfeffer21-Jan-15 0:40 
AFAIK, the XML serialization code works by examining the class' members, and outputting code to read / write them. This works very well for fixed-format XML fragments, but fails when you want to parse variable fragments.

In your example, the result tag has two possible formats. The XML deserializer has no way of knowing which format is to be used, and therefore it reports an error when trying to parse the second format.

I know of no way to define variable fragments using C# attributes. If you control both ends of the link, you might try creating a separate tag for each XML message type and ensuring that each XML message type has a unique class associated with it. You might have XML classes inherit from a common interface, so that the same data may be returned from each:

C#
interface XmlBase
{
    IList< XmlResult > Results { get; }
}

[Serializable]
[XmlType("response1")]
class XmlResponse1: XmlBase
{
    // implementation goes here
}

[Serializable]
[XmlType("response2")]
class XmlResponse2: XmlBase
{
    // implementation goes here
}

If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.

--Winston Churchill

GeneralRe: Deserialize Parts of an XML Pin
Antonio Cambule21-Jan-15 0:56
Antonio Cambule21-Jan-15 0:56 
GeneralRe: Deserialize Parts of an XML Pin
Daniel Pfeffer21-Jan-15 2:51
professionalDaniel Pfeffer21-Jan-15 2:51 
AnswerRe: Deserialize Parts of an XML Pin
Gerry Schmitz21-Jan-15 13:00
mveGerry Schmitz21-Jan-15 13:00 
QuestionIE 11 Registry Entries Pin
namerg20-Jan-15 11:43
namerg20-Jan-15 11:43 
AnswerRe: IE 11 Registry Entries Pin
Pete O'Hanlon20-Jan-15 11:50
mvePete O'Hanlon20-Jan-15 11:50 
GeneralRe: IE 11 Registry Entries Pin
namerg20-Jan-15 11:57
namerg20-Jan-15 11:57 
GeneralRe: IE 11 Registry Entries Pin
Pete O'Hanlon20-Jan-15 12:14
mvePete O'Hanlon20-Jan-15 12:14 
GeneralRe: IE 11 Registry Entries Pin
namerg20-Jan-15 14:13
namerg20-Jan-15 14:13 
QuestionHex to UUEncode in C# Pin
NJdotnetdev20-Jan-15 2:04
NJdotnetdev20-Jan-15 2:04 
AnswerRe: Hex to UUEncode in C# Pin
OriginalGriff20-Jan-15 2:50
mveOriginalGriff20-Jan-15 2:50 
GeneralRe: Hex to UUEncode in C# Pin
NJdotnetdev20-Jan-15 3:24
NJdotnetdev20-Jan-15 3:24 
GeneralRe: Hex to UUEncode in C# Pin
OriginalGriff20-Jan-15 3:35
mveOriginalGriff20-Jan-15 3:35 
GeneralRe: Hex to UUEncode in C# Pin
NJdotnetdev20-Jan-15 3:43
NJdotnetdev20-Jan-15 3:43 
GeneralRe: Hex to UUEncode in C# Pin
OriginalGriff20-Jan-15 4:01
mveOriginalGriff20-Jan-15 4:01 
GeneralRe: Hex to UUEncode in C# Pin
NJdotnetdev20-Jan-15 4:42
NJdotnetdev20-Jan-15 4:42 
GeneralRe: Hex to UUEncode in C# Pin
OriginalGriff20-Jan-15 4:57
mveOriginalGriff20-Jan-15 4:57 
GeneralRe: Hex to UUEncode in C# Pin
NJdotnetdev20-Jan-15 5:00
NJdotnetdev20-Jan-15 5:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.