Hi i have more than 20 links of xml files. I searched a lot to convert my xml to c# and then deserialize it according to classes and then put it into the database but not found a good solution for that. Please help me how to do it.
http://kithnyc.com/sitemap_products_1.xml?from=60594372&to=9586327751
This is the link of database and some xml is below
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<url>
<loc>http://kithnyc.com/</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>
http://kithnyc.com/products/adidas-originals-nmd-city-sock-black-blue
</loc>
<lastmod>2016-09-12T11:04:04-04:00</lastmod>
<changefreq>daily</changefreq>
<image:image>
<image:loc>...</image:loc>
<image:title>adidas Originals NMD City Sock - Black / Blue</image:title>
</image:image>
</url>
<url>
<loc>
http://kithnyc.com/products/kith-logo-mousepad-white
</loc>
<lastmod>2016-12-23T00:01:41-05:00</lastmod>
<changefreq>daily</changefreq>
<image:image>
<image:loc>
https://cdn.shopify.com/s/files/1/0094/2252/products/20150810-_MG_2963.jpg?v=1482353363
</image:loc>
<image:title>Kith Logo Mousepad - White</image:title>
</image:image>
</url>
</urlset>
This is the xml i want to put all its nodes in the database like "Loc" , "lastmod" and "changefreq" etc. Please help me how to convert it into classes and then how to deserialize it. Thanks
Hi you can do it like this:
Step 1: Read the file by the below line
Step 2: The get all node of xml by Descendants method and convert it into list. if need apply where clause to filter that data.
Step 3: Create data table and store all the data in data table from list like
Step 4 : Then you can save it db and you can avoid the step 4 and directly store date from list to data base