Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have some XML stored in a single column of a table. I have written the following SQL query but get nothing back. Can somebody a bro xml novice in a bind out with some suggestions?

XML
<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdtc="urn:hl7-org:sdtc">
  <realmCode code="US" />
  <typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040" />
  <templateId root="2.16.840.1.113883.10.20.22.1.1" />
  <templateId root="2.16.840.1.113883.10.20.22.1.2" />
  <id root="3d0b09e1-2014-f0a8-05cf-001A64958C30" />
  <code code="34133-9" codeSystem="2.16.840.1.113883.6.1" displayName="Summarization of Episode Note" />
  <title>Ambulatory Summary</title>
</ClinicalDocument>





DECLARE @XMLDoc AS XML, @hDoc AS INT, @SQL NVARCHAR(MAX)

SELECT @XMLDoc = XMLData FROM XMLwithOpenXML

EXEC sp_xml_preparedocument @hDoc OUTPUT, @XMLDoc, '<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdtc="urn:hl7-org:sdtc" />'

SELECT Title
FROM OPENXML(@hDoc, '/sdtc:ROOT/sdtc:ClinicalDocument',1)
WITH
(
Title varchar(50) 'sdtc:title'
)

EXEC sp_xml_removedocument @hDoc
Posted
Updated 13-Nov-14 8:39am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900