Parsing XML file to create inserts to Database

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi, hopefully this is the right place to post this. I am working on an application which needs to be able to parse an XML file and create inserts to push the data in the XML into tables in my database. I am using the Entity framework to connect to the database.
Basically I will have an XML file that looks something like this:

<ResidentHouse title="Test ResidentHouse" isCorporate="true" regionId="1" costSectorId="442DE19C-A9ED-4D0F-B872-59BE64FD5742
<MasterMenu title="Test Corporate Master Menu" description="Test Corporate Menu" startDate="2012-01-01" endDate="2012-12-31" isPublished="true
<Menu title="Breakfast" classification="Breakfast" ordinal="113
<MenuFoodCategory title="Hot Cereal" alternateTitle="Cold Cereal - Alternative" textureProfile ="Dessert" isItemsAvailableGroup="false" reportOptionIsNutrient="false" reportOptionIsProduction="false" ordinal="2
<MenuItem title="Rice Krispies" portionAdjustment="1.00" portionSize="30.00" portionUOM="gram" recipeCost="0.276" forecastPortions="40.00" forecastAdjustmentIsPercentage="false" forecastAdjustment="0.00" recipeItemId="F1924136-93BF-43BB-A621-50BC015556CA"
texture="Regular" dietType="Modified Renal" menuItemType="Choice 2" weekday="Thursday" week="1" ordinal="1" />
</MenuFoodCategory>
</Menu>
</MasterMenu>
<Wing title="North
<Room title="001
<Resident lastName="Lee" firstName="Bruce" salutation="Mr." gender="1" dateOfBirth="1960-10-19" menuTypeSelect="Choice" height="165" currentWeight="70" isProfileCompleted="true" />
</Room>
</Wing>
</ResidentHouse>
I will need to be pushing information into quite a few different tables as outlined by the XML structure and obviously cascading primary and foreign keys down as I go. Can anyone point me in the right direction to get started on this? Sort of new to working
with XML and would appreciate any insight. Thanks!



View the full article
 
Back
Top