I have the following (snippet) of xml code in a SQL table colum designated as xml datatype.
<RequirementInfo AppliesToPartyID="INS_1_L9019226" FulfillerPartyID="VENDOR_EMSI" id="REQ_L9019226_476043_0000_5">
<ReqCode tc="5">Collect Urine Specimen (HOS)</ReqCode>
<RequirementInfoKey>L9019226_476043_0000_5</RequirementInfoKey>
<RequirementInfoSysKey SystemCode="PLUS" VendorCode="0029">476043</RequirementInfoSysKey>
<HORequirementRefID>5</HORequirementRefID>
...etc
I can easily pull out the xml element data using the following:
SELECT xml_data.query ('data(//RequirementInfo[1]//ReqCode)') as [XML Sections]
FROM dbo.XmlImportTest
My question is, what would the syntax be to read out an ATTRIBUTE in the above xml code snippet, like the tc attribute = "5" in the element 'ReqCode' ??
Thanks for any help you can provide.
<RequirementInfo AppliesToPartyID="INS_1_L9019226" FulfillerPartyID="VENDOR_EMSI" id="REQ_L9019226_476043_0000_5">
<ReqCode tc="5">Collect Urine Specimen (HOS)</ReqCode>
<RequirementInfoKey>L9019226_476043_0000_5</RequirementInfoKey>
<RequirementInfoSysKey SystemCode="PLUS" VendorCode="0029">476043</RequirementInfoSysKey>
<HORequirementRefID>5</HORequirementRefID>
...etc
I can easily pull out the xml element data using the following:
SELECT xml_data.query ('data(//RequirementInfo[1]//ReqCode)') as [XML Sections]
FROM dbo.XmlImportTest
My question is, what would the syntax be to read out an ATTRIBUTE in the above xml code snippet, like the tc attribute = "5" in the element 'ReqCode' ??
Thanks for any help you can provide.