What is difference between xmlns:i and xmlns:xsi attributes in XML format? And how to query for xmlns:i value in SQL Server?

Viewed 223

Below is my XML column data sample in SQL Table column of XML type.

<MyRootNode xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" z:Id="i1">
  <MyValue>This is sample text</MyValue>
</MyRootNode>

I try retrieve the xml node value as follows;

SELECT MY_XML_COLUMN.value('(/MyRootNode/MyValue)[1]', 'varchar') FROM MY_TABLE

The above returns NULL. However, if the XML is stored in table with xmlns:xsi, it is correctly returning the value.

The xml column is being saved using xml.runtime.serialization, it is storing this way. Any help appreciated on querying this from SQL side rather than attempt to fix the saving part from the program which is costly. Thanks

0 Answers
Related