Venkatesh Pettem

Venkatesh Pettem

  • 1.6k
  • 268
  • 986

How to read xml nodes data

Jul 2 2019 3:18 AM
I'm trying to read xml node in sql server, i couldn't able to read the node data, can any one help me,
 
Below is xml Content:
 
<entry>
<entryRelationship typeCode="SUBJ">
<encounter classCode="ENC" moodCode="EVN">
<code code="32485007" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT"/>
<sdtc:dischargeDispositionCode code="428371000124100" codeSystem="2.16.840.1.113883.6.96" codeSystemName="SNOMED-CT"/>
</encounter>
</entryRelationship>
</act>
</entry>
 
The bold node im not able to read. Below im trying in sql server
 
select
Code = x.v.value('(code/@code)[1]', 'VARCHAR(100)') ,
DispositionCode= x.v.value('(------?-------)[1]', 'VARCHAR(100)')
FROM @XMLValue.nodes('entry/entryRelationship/encounter') x(v)

Answers (1)