Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Parsing XML file using C#

$
0
0

Hi everyone,

I have the following XML file that I am trying to parse using C#:

<?xml version="1.0" encoding="utf-8" ?><orders><order><order_date>1/14/2014</order_date><customer_id>001</customer_id><product><product_id>sh_s</product_id><product_qt>4</product_qt></product><product><product_id>sh_m</product_id><product_qt>9</product_qt></product><product><product_id>pa_32s</product_id><product_qt>13</product_qt></product><product><product_id>ja_l</product_id><product_qt>1</product_qt></product></order><order><order_date>1/15/2014</order_date><customer_id>002</customer_id><product><product_id>sh_s</product_id><product_qt>5</product_qt></product><product><product_id>sh_m</product_id><product_qt>21</product_qt></product><product><product_id>pa_32s</product_id><product_qt>14</product_qt></product><product><product_id>ja_l</product_id><product_qt>11</product_qt></product></order><order><order_date>1/15/2014</order_date><customer_id>003</customer_id><product><product_id>sh_s</product_id><product_qt>8</product_qt></product><product><product_id>sh_m</product_id><product_qt>20</product_qt></product><product><product_id>pa_32s</product_id><product_qt>16</product_qt></product><product><product_id>ja_l</product_id><product_qt>18</product_qt></product></order>

I am trying to store the data into a database with two tables:

1) First Table:

      a) includes an auto generated order number (Primary key)

      b) order date

      c) customer ID

2)Second Table:

      a) includes an auto generated order number (Primary key)

      b) Product ID (Primary Key)

      c) Product Quantity

The two table have the same order number in order to create a relationship. Basically I want to store the information of each order and its correspondent products.

The number of <order> in the XML file will be unknown (it may vary) and so will the number of <product>.

Any suggestions on how to address this problem?

Thank You



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>