August 30, 2010 at 12:33 am
<HousingLoan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MemberData>
<Name>alan</Name>
</MemberData>
<FinanciarData>
<Source>Bank</Source>
</FinanciarData>
</HousingLoan>
Attached with sample XML, anybody can help on select the FinanciarData->Source with double namespace define in the header. Thanks.
August 30, 2010 at 3:48 am
You need to include the namespace declaration in your SELECt statement.
Assuminig you're using SS2K5 or SS2K8, here's the XQuery snippet I would use:
declare @xml xml
set @xml='<HousingLoan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MemberData>
<Name>alan</Name>
</MemberData>
<FinanciarData>
<Source>Bank</Source>
</FinanciarData>
</HousingLoan>'
;
WITH XMLNAMESPACES
('http://www.w3.org/2001/XMLSchema-instance' as xsi,
'http://www.w3.org/2001/XMLSchema' as xsd
)
SELECT
c.value('Source[1]','VARCHAR(10)') as source
FROM
@xml.nodes('HousingLoan/FinanciarData') T(c)
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply