vihrao

vihrao
- Name: [not set]
- Favorite Languages: [not set]
- Website: [not set]
- Location: [not set]
- About Me: [not set]
-
C# Tutorial - XML Serialization
09/14/2010 - 13:41
The later part of my posting got garbled. Sorry. I am repostng only that part.
The serialized output looks like this:
<ProblemType>
<DateTime>
<DateTimeType>
<Type><Text>Episode Begin Datetime</Text></Type>
<ExactDateTime>04/01/2010</ExactDateTime>
</DateTimeType>
<DateTimeType>
<Type><Text>Episode End Datetime</Text></Type>
<ExactDateTime>04/02/2010</ExactDateTime>
</DateTimeType>
</DateTime>
</ProblemType>There is slight problem. I have to get rid of the tag because the receiving program does not validate the tag.
My sericalzed XML should look like this:
ProblemType>
<DateTime>
<Type><Text>Episode Begin Datetime</Text></Type>
<ExactDateTime>04/01/2010</ExactDateTime>
</DateTime>
<DateTime>
<Type><Text>Episode End Datetime</Text></Type>
<ExactDateTime>04/02/2010</ExactDateTime>
</DateTime>
</ProblemType>
Can you please tell me how to get this problem solved? -
C# Tutorial - XML Serialization
09/14/2010 - 13:36
I have problems in serializing a list.
Here is my class:
public partial class ProblemType
{
private List<DateTimeType> dateTimeField;
public ProblemType()
{
this.dateTimeField = new List<DateTimeType>();
}
public List<DateTimeType> DateTime
{
get
{
return this.dateTimeField;
}
set
{
this.dateTimeField = value;
}
}
}
public partial class DateTimeType
{
private CodedDescriptionType2 typeField;
private string exactDateTimeField;
public DateTimeType()
{
this.typeField = new CodedDescriptionType2();
}
public CodedDescriptionType2 Type
{
get
{
return this.typeField;
}
set
{
this.typeField = value;
}
}
public string ExactDateTime
{
get
{
return this.exactDateTimeField;
}
set
{
this.exactDateTimeField = value;
}
}
}
Here is how I call the code:
ProblemType pt = new ProblemType();
pt.DateTime = GetDateTimeRange();
public List<DateTimeType> GetDateTimeRange()
{
List< DateTimeType> dttList = new List< DateTimeType>();
DateTimeType dtt1 = new CCRG.DateTimeType();
DateTimeType dtt2 = new CCRG.DateTimeType();
dtt1.Type = GetType1();
dtt1.ExactDateTime = GetExactdateTime1();
dttList.Add(dtt1);
dtt2.Type = GetType2();
dtt2.ExactDateTime = GetExactdateTime2();
dttList.Add(dtt2);
return dttList;
}
When I run the code I get serialized XML like this:
<ProblemType>
<DateTime>
<DateTimeType>
<Type><Text>Episode Begin Datetime</Text></Type>
<ExactDateTime>04/01/2010</ExactDateTime>
</DateTimeType>
<DateTimeType>
<Type><Text>Episode End Datetime</Text></Type>
<ExactDateTime>04/02/2010</ExactDateTime>
</DateTimeType>
</DateTime>
</ProblemType>
[/langauge]
There is slight problem. I have to rid of the tag <DateTimeType> because the receiving program does not validate the tag.
IMy sericalzed XMl should look like this:
[language]<ProblemType>
<DateTime>
<Type><Text>Episode Begin Datetime</Text></Type>
<ExactDateTime>04/01/2010</ExactDateTime>
</DateTime>
<DateTime>
<Type><Text>Episode End Datetime</Text></Type>
<ExactDateTime>04/02/2010</ExactDateTime>
</DateTime>
</ProblemType>
[/langauge]
Can you tell me how to this problem solved?
Recent Comments