2

I'm using SQL Server 2008 and I'm having trouble getting all data out of this xml:

DECLARE @xml xml

SELECT @xml =
'<dlines id="1234">
  <dline time="16h49" order="1">bladibla</dline> 
  <dline time="16h50" order="2">more bladibla</dline> 
</dlines>'

I can get the values of the attributes of the dline element using:

SELECT  TimeStr = dLine.value('@time', 'nvarchar(20)'),
OrderNo = dLine.value('@order', 'int'),
StatusStr = dLine.value('@status', 'nvarchar(20)'),
PeriodStr = dLine.value('@period', 'nvarchar(20)')
FROM    @afpxml.nodes('/dlines/dline') as XTbl(dLine)

But how do I get the value of dline element itself (the 'bladibla1')?

Thnx a lot for your help!

1 Answer 1

1

Just query the value of ., the current node:

DlineItself = dLine.value('.', 'nvarchar(20)')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.