Click here to Skip to main content
15,889,216 members
Home / Discussions / C#
   

C#

 
GeneralRe: Decimal compare Pin
Mycroft Holmes7-Oct-17 14:38
professionalMycroft Holmes7-Oct-17 14:38 
AnswerRe: Decimal compare Pin
Luc Pattyn6-Oct-17 4:53
sitebuilderLuc Pattyn6-Oct-17 4:53 
AnswerRe: Decimal compare Pin
C. David Johnson6-Oct-17 5:56
C. David Johnson6-Oct-17 5:56 
GeneralRe: Decimal compare Pin
Luc Pattyn6-Oct-17 6:06
sitebuilderLuc Pattyn6-Oct-17 6:06 
GeneralRe: Decimal compare Pin
C. David Johnson6-Oct-17 6:13
C. David Johnson6-Oct-17 6:13 
AnswerRe: Decimal compare Pin
Gerry Schmitz7-Oct-17 5:48
mveGerry Schmitz7-Oct-17 5:48 
QuestionDeserialization issue (Should be easy) Pin
C. David Johnson5-Oct-17 9:38
C. David Johnson5-Oct-17 9:38 
AnswerRe: Deserialization issue (Should be easy) Pin
Richard Deeming6-Oct-17 2:25
mveRichard Deeming6-Oct-17 2:25 
Assuming the extra spaces in your sample XML aren't actually present in your file, there are two problems.

First, the KeyType element is too high. You've declared that it's taken from the DATA node, but it's actually a descendant of that node.

Second, the Value property needs to be decorated with the [XmlText] attribute.
C#
[Serializable]
[XmlRoot("DTAXDOC", Namespace = "", IsNullable = false)]
public class DTAxType
{
    [XmlElement("DATA")]
    public DataType[] Data { set; get; }
}

[Serializable]
[XmlType("DATA")]
public class DataType
{
    [XmlElement("KEY")]
    public KeyType[] Key { set; get; }
}

[Serializable]
[XmlType("KEY")]
public class KeyType
{
    [XmlAttribute("FIELDID")]
    public int FieldId { set; get; }
    
    [XmlText]
    public string Value { set; get; }
}

With those changes in place, your sample XML deserializes to:
new DTAxType
{
    Data = new[]
    {
        new DataType
        {
            Key = new[]
            {
                new KeyType
                {
                    FieldId = 1,
                    Value = "Hello World"
                }
            }
        }
    }
}




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


AnswerRe: Deserialization issue (Should be easy) Pin
C. David Johnson6-Oct-17 5:03
C. David Johnson6-Oct-17 5:03 
QuestionHeisenbug in program without async, etc. Pin
Alexander Kindel5-Oct-17 6:47
Alexander Kindel5-Oct-17 6:47 
AnswerRe: Heisenbug in program without async, etc. Pin
harold aptroot5-Oct-17 10:42
harold aptroot5-Oct-17 10:42 
GeneralRe: Heisenbug in program without async, etc. Pin
Alexander Kindel5-Oct-17 11:28
Alexander Kindel5-Oct-17 11:28 
GeneralRe: Heisenbug in program without async, etc. Pin
harold aptroot5-Oct-17 12:32
harold aptroot5-Oct-17 12:32 
GeneralRe: Heisenbug in program without async, etc. Pin
Alexander Kindel5-Oct-17 12:50
Alexander Kindel5-Oct-17 12:50 
GeneralRe: Heisenbug in program without async, etc. Pin
harold aptroot5-Oct-17 23:17
harold aptroot5-Oct-17 23:17 
GeneralRe: Heisenbug in program without async, etc. Pin
Alexander Kindel5-Oct-17 22:22
Alexander Kindel5-Oct-17 22:22 
QuestionHelp with a Windows Form Application parser Pin
Member 134478105-Oct-17 4:59
Member 134478105-Oct-17 4:59 
QuestionRe: Help with a Windows Form Application parser Pin
Eddy Vluggen7-Oct-17 3:13
professionalEddy Vluggen7-Oct-17 3:13 
AnswerRe: Help with a Windows Form Application parser Pin
Member 134478109-Oct-17 6:43
Member 134478109-Oct-17 6:43 
GeneralRe: Help with a Windows Form Application parser Pin
Eddy Vluggen9-Oct-17 7:31
professionalEddy Vluggen9-Oct-17 7:31 
Questionhow to show sql server row wise data in column wise in dynamic table Pin
Member 127429835-Oct-17 1:08
Member 127429835-Oct-17 1:08 
AnswerRe: how to show sql server row wise data in column wise in dynamic table Pin
Richard MacCutchan5-Oct-17 1:14
mveRichard MacCutchan5-Oct-17 1:14 
QuestionAjax based filled DropDown Reset on Page Postback in Asp.Net Pin
khaqanbaloch4-Oct-17 18:33
professionalkhaqanbaloch4-Oct-17 18:33 
AnswerRe: Ajax based filled DropDown Reset on Page Postback in Asp.Net Pin
Richard MacCutchan4-Oct-17 22:37
mveRichard MacCutchan4-Oct-17 22:37 
QuestionJson login with authentification and getting the result in C# Pin
Member 113544104-Oct-17 17:15
Member 113544104-Oct-17 17:15 

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.