I'm very new to XML query and having trouble with the query below. Can anyone help me, please?
I am not getting any data from the query below. But somehow I figured that that removing the row xmlns="http://www.w3.org/1999/xhtml from XML data works fine.
However, the original XML data contains this row. Hence, not sure how to write correct SQL.
create table xmltest (col xml null)
insert into xmltest values('
<xml xmlns="http://www.w3.org/1999/xhtml" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:ix="http://www.xbrl.org/2008/inlineXBRL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="-//XBRL International//DTD XHTML Inline XBRL 1.0//EN">
<ix:nonnumeric contextref="CurrentAccumulatedQ3Instant" name="tse-ed-t:DocumentName">aaa</ix:nonnumeric>
<ix:nonnumeric contextref="CurrentAccumulatedQ3Instant" format="ixt:dateerayearmonthdayjp" name="tse-ed-t:FilingDate">bbb</ix:nonnumeric>
<ix:nonnumeric contextref="CurrentAccumulatedQ3Instant" name="tse-ed-t:CompanyName">ccc</ix:nonnumeric>
<ix:nonnumeric contextref="CurrentAccumulatedQ3Instant" format="ixt:booleantrue" name="tse-ed-t:TokyoStockExchange">ddd</ix:nonnumeric>
<ix:nonnumeric contextref="CurrentAccumulatedQ3Instant" format="ixt:booleanfalse" name="tse-ed-t:StockExchange" />
</xml>
')
select
T.Col.value('fn:local-name(.)','nvarchar(max)'),
T.Col.value('.','nvarchar(max)')
from xmltest
cross apply col.nodes('
declare namespace aaa="http://www.w3.org/1999/xhtml";
declare namespace ix="http://www.xbrl.org/2008/inlineXBRL";
//xml/ix:*'
) as T(Col)