XML schema to convert XML file into relational format



I have an XML file and want to transfer the contents to a SQL Server 2014 database. I believe I need to write an XML mapping schema and then follow the example here: http://ift.tt/1E2jI3D


The trouble is I don't know how to write a schema that will map to a table with the following columns/fields:


Product Item (Primary Key)

Category ID

Weight

Product Name

Model

Price

Image

Description


The sample XML file is as follows:



<?xml version="1.0" ?>
<STOREITEMS>
<CREATED>
<CATEGORY id='181' name='Category name'>
<PRODUCT ITEM='7451'>
<WEIGHT>0.50</WEIGHT>
<NAME>Product name</NAME>
<MODEL>Product model</MODEL>
<PRICE>£5.99</PRICE>
<IMAGE>image.jpg</IMAGE>
<DESCRIPTION>Product description.</DESCRIPTION>
</PRODUCT>
</CATEGORY>
</CREATED>
</STOREITEMS>


In the full file there may be multiple "products" within a "category", and there may also be multiple categories.


No comments:

Post a Comment