© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
17 replies
CatSandwich

✅ Configure Xml Serialization

Hey folks! I have a type like this:
class DateTimeWrapper
{
    public DateTime Value;
}
class DateTimeWrapper
{
    public DateTime Value;
}

I'm serializing this via System.Xml. I would like to have this type serialize as if I were serializing the wrapped
Value
Value
, rather than the whole type.

In other words, I want it to serialize as this:
2023-08-04 00:00:00
2023-08-04 00:00:00
rather than
<Value>
    2023-08-04 00:00:00
</Value>
<Value>
    2023-08-04 00:00:00
</Value>

What are my options to make this happen? I would ideally like to avoid changing the serializer itself, but rather use an approach that the serializer will respect. For example, newtonsoft json uses
JsonConverter
JsonConverter
, but I'm not sure if System.Xml has a similar concept.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ XML Serialization
C#CC# / help
4y ago
❔ XML serialization woes
C#CC# / help
4y ago
❔ XML serialization - internal XML element
C#CC# / help
4y ago
Serialization abstract class and it's child's into xml
C#CC# / help
2y ago