© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago
orlac

Parsing XML directly into serializable object?

I wrote a snippet of code to handle parsing an XML document into an
IAsyncEnumerable
IAsyncEnumerable
of objects containing all of the necessary xml attributes/element data I want to capture, but was reading a bit about some better techniques for this type of thing and noticed some stackoverflow posts mentioning a method that's possible by using a type that's tagged with
Serializable
Serializable
. The only issue is that I can't seem to find examples of how to do this.

Is there an simple modification to this code here to be able to deserialize an
XElement
XElement
directly into a
Compound
Compound
object? The code is already starting to get messy and am hoping there's something I can use to either infer the schema of the XML document, then use that to serialize... or if possible just serialize into the object directly.

This is the code I'd like to simplify with this type of an approach if possible:
https://github.com/vorlac/cppreference-docs-vs-extension/blob/main/DocumentationProcessor/Core/Indexer.cs#L51-L145

And this is the XML doc being parsed:
https://gist.github.com/vorlac/0514ed1920eb69d00e00af7631c1a528

Any help with the syntax needed to handle that conversion would be appreciated (or alternative parsing approaches altogether). The plan is to parse out as much info as possible, then store the data in a sqlite database, so if there are any shortcuts to pull that off (i.e. something that would allow a direct XML => sqlite transform).
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
C#CC# / help
4y ago
❔ ✅ Parsing path into parts with varying separators?
C#CC# / help
3y ago
❔ ✅ Serializable attribute in Unity
C#CC# / help
3y ago
❔ XML deserialise different types into a single list
C#CC# / help
3y ago