Skip to content
Advertisement

Best way to import XML into a database C# .NET Core

I’m working on a project that requires that I take data from an XML API that I don’t control and insert that data into a database (I control) for consumption by a different application (I control but can’t modify code too it)

We already managed to get the full database layout from the XML API via the providers special endpoint but all other queries (to get data) are via XML.

Currently what I have is the following:

Book.cs – This represents one of the database tables

API Return XML – This represents the XML returned by the API (an SDK already converts it to an XMLDocument Type)

Currently the way we are doing this is via switch statements, but I’m hoping that there is a better method. Partial BookController.cs

I have a feeling that there is a much easier method of doing this that I’m just unaware of, my concern is that I have about fifty tables and hundreds of elements to do making this method inefficient time wise.

Advertisement

Answer

Use xml serialization

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement