How to use a sealed class hierarchy with differing root elements? #98
Labels
bug
Something isn't working
enhancement
New feature or request
indev
The issue is fixed/implemented in the dev branch
How to use a sealed class hierarchy with differing root elements?
I'm writing a HTTP client for a web service that returns a different XML based
on whether records are found or not. I've described a simplified version of my
use-case below.
When records are found the API returns a
cars
root element withcar
elements inside it:
When no records are found it returns a single
car
root element instead:I've tried the following approach using
xmlutil
:Program output:
When working with JSON I would use
JsonContentPolymorphicSerializer
to selectthe serializer based on what keys are found in the object. Though for obvious
reasons not an option here. I've went through at the documentation, examples
and issues but I'm unable to figure out how to approach this issue.
Any suggestions how I could approach serializing above XML into a sealed class
using xmlutil?
The text was updated successfully, but these errors were encountered: