This is a simple example of how to extract a value from a mastercook 5(?) recipe format.
The XML Section of 70-431 was monotonous, so I used my recipe program that exports to MasterCook to help me out.
---------------------CODE--------------------------
declare @int int
declare @XML VARCHAR(MAX)
set @XML = '<mx2 source="MasterCook" date="January 23, 2009"> <Summ><Nam> Vegetarian Sloppy Joes </Nam></Summ> <RcpE name="Vegetarian Sloppy Joes" author="">
<Serv qty="6"/> <PrpT elapsed="0:00"/> <CatS> <CatT> Main Dish </CatT> <CatT>
try </CatT> </CatS>
<IngR name="vegetable oil" unit="tablespoon" qty="1"></IngR>
<IngR name="onion" unit="medium" qty="1">
<IPrp>
chopped
</IPrp>
</IngR>
<IngR name="green pepper" qty="1">
<IPrp>
chopped
</IPrp>
</IngR>
<IngR name="cooked brown rice" unit="cups" qty="3"></IngR>
<IngR name="Mexican style pinto beans" unit="16-ounce cans" qty="2">
<INtI>
4510
</INtI>
</IngR>
<IngR name="hickory smoke barbecue sauce" unit="cup" qty="3/4">
<INtI>
3962
</INtI>
</IngR>
<IngR name="whole grain buns (4 to 6)" qty="4">
<INtI>
3667
</INtI>
</IngR>
<DirS>
<DirT>
Heat oil in large skillet over medium-high heat. Add onion and green pepper; cook 2 to 3 minutes. Add rice, beans and barbecue sauce. Simmer 10 to 15 minutes, until heated through. Serve on buns.

Makes 4 to 6 servings. </DirT> </DirS> <Srce> The Rice Council </Srce> <AltS label="Internet address" source="http://www.usarice.com/domestic/recipes/"/> <Nutr> Per Serving (excluding unknown items): 341 Calories; 6g Fat (14.8% calories from fat); 13g Protein; 61g Carbohydrate; 9g Dietary Fiber; 1mg Cholesterol; 864mg Sodium. Exchanges: 3 1/2 Grain(Starch); 1/2 Lean Meat; 1/2 Vegetable; 1 Fat; 0 Other Carbohydrates.
</Nutr>
</RcpE></mx2>'
exec sp_xml_preparedocument @int OUTPUT , @XML
select * from openxml
(
@int,
'mx2/Summ/Nam',1
)where text is not null
--------------------------------
No comments:
Post a Comment