Actually, have another problem, it's appearing it's concatinating the items together. Here is the actual example. I think this is all being generated from VS.NET, so I'm not sure what some of the name spaces and attributes are for. Is there any way to make them not concatinate like the first example? Thanks a million.
DECLARE @.idoc int
DECLARE @.doc varchar(5000)
SET @.doc ='
<RS_DN_Objective xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<mDocType>2</mDocType>
<SectionID>O0</SectionID>
<IsLoaded>true</IsLoaded>
<sTreat>
<mArr>
<anyType xsi:type="xsdtring">Modality - IFC E-Stim</anyType>
<anyType xsi:type="xsdtring">Hamstring Curl Resisted (Sitting)</anyType>
<anyType xsi:type="xsdtring">Hip Abduction Adduction with Extended Knee (Sup</anyType>
<anyType xsi:type="xsdtring">Hip Abduction Adduction with Knee Flexion (Supine)</anyType>
</mArr>
</sTreat>
</RS_DN_Objective>
'
EXEC sp_xml_preparedocument @.idoc OUTPUT, @.doc
SELECT *
FROM OPENXML (@.idoc, 'RS_DN_Objective/sTreat/mArr',2)
WITH (anyType VARCHAR(100) '.')
EXEC sp_xml_removedocument @.idoc
My Results Are:
'
'anyType
'Modality - IFC E-Stim Hamstring Curl Resisted (Sitting) Hip Abduction Adduction with Extended Kn
'
Are you using SQL 2000 or SQL 2005?|||
Try changing your SELECT statement to something like:
Code Snippet
SELECT anyType
FROM OPENXML (@.idoc, 'RS_DN_Objective/sTreat/mArr/anyType',2)
WITH (anyType VARCHAR(100) '.')
/*
anyType
Modality - IFC E-Stim
Hamstring Curl Resisted (Sitting)
Hip Abduction Adduction with Extended Knee (Sup
Hip Abduction Adduction with Knee Flexion (Supine)
*/
Another alternative is something like:
Code Snippet
declare @.doc xml
SET @.doc ='
<RS_DN_Objective xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<mDocType>2</mDocType>
<SectionID>O0</SectionID>
<IsLoaded>true</IsLoaded>
<sTreat>
<mArr>
<anyType xsi:type="xsdtring">Modality - IFC E-Stim</anyType>
<anyType xsi:type="xsdtring">Hamstring Curl Resisted (Sitting)</anyType>
<anyType xsi:type="xsdtring">Hip Abduction Adduction with Extended Knee (Sup</anyType>
<anyType xsi:type="xsdtring">Hip Abduction Adduction with Knee Flexion (Supine)</anyType>
</mArr>
</sTreat>
</RS_DN_Objective>
'
select t.value('.', 'varchar(100)') as anyType
from @.doc.nodes('RS_DN_Objective/sTreat/mArr/anyType') as x(t)
/*
anyType
Modality - IFC E-Stim
Hamstring Curl Resisted (Sitting)
Hip Abduction Adduction with Extended Knee (Sup
Hip Abduction Adduction with Knee Flexion (Supine)
*/
No comments:
Post a Comment