I was wondering if anyone could point me to a tutorial or give me suggestions on processing an XML "Request For Quote" document. Using SQL Server 2005. For example:
<MyQuote>
<Header>
<Customer>XYZ</Customer>
<Material>Wood&</Material>
<Header>
<LineItems>
<Line>
<Quantity>32</Quantity>
<Model>Chair 350</Model>
<Color>Red</Color>
</Line>
.
</LineItems>
</MyQuote>
Just getting my feet wet with XQuery. I need to shred this doc into individual Line Items, identify each one with a number, validate them calc a price. Also need to be able to add/edit/delete any one. I can see how to get the lines into a table, but not how to ID them with a sequential number and apply a Stored Procedure to them. I need to randomly be able to process any request such as validate line 6
, calc price for line 3
delete line 4
, change line 2 to Yellow
, etc.
I'm assuming the best way is to store the entire document as an XML column and transact against it as opposed to shredding and storing individual line items in a relational table?
Any advice, code, urls, etc would be greatly appreciated.
Here is some useful pages:
This will give you all lines:
Not so easy. Have a look at this answer. XQuery and Node Ids
Just use modify() Method (xml Data Type)
To get line 6 you should to this:
/MyQuote/LineItems/Line[6]
is the same as/MyQuote/LineItems/Line[position()=6]
Don't know what is best for you but I would definitely shred the data to tables unless there where some really compelling reasons not to.