How to select the value of the xsi:type attribute in SQL Server?
        Posted  
        
            by kralizek
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by kralizek
        
        
        
        Published on 2010-03-19T12:35:23Z
        Indexed on 
            2010/03/19
            12:41 UTC
        
        
        Read the original article
        Hit count: 384
        
Considering this xml document:
DECLARE @X XML (DOCUMENT search.SearchParameters)  = '< parameters xmlns="http://www.educations.com/Search/Parameters.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  < parameter  xsi:type="category" categoryID="38" />
< /parameters>';
I'd like to access the value of the attribute "type".
According to this blog post, the xsi:type attribute is special and can't be accessed by usal keywords/functions.
How can I do it?
PS: I tried with
    WITH XMLNAMESPACES (
 'http://www.educations.com/Search/Parameters.xsd' as p,
 'http://www.w3.org/2001/XMLSchema-instance' as xsi
    )
    SELECT @X.value('(/p:parameters/p:parameter/@xsi:type)[1]','nvarchar(max)')
but it didn't work.
© Stack Overflow or respective owner