Reading xml Structure in sql server 2012



Sample Xml Structure



<?xml version="1.0" encoding="UTF-8"?>
<XmlSerializableHashtable xmlns:xsd="http://ift.tt/tphNwY" xmlns:xsi="http://ift.tt/ra1lAU">
<Entries>
<Entry>
<key xsi:type="xsd:string">col1</key>
<value xsi:type="xsd:string">500</value>
</Entry>
<Entry>
<key xsi:type="xsd:string">col2</key>
<value xsi:type="xsd:string">0/60,1/1000</value>
</Entry>
<Entry>
<key xsi:type="xsd:string">col3</key>
<value xsi:type="xsd:string">localhost</value>
</Entry>
</Entries>
</XmlSerializableHashtable>


No i am trying to get value where key is col3


I am trying with the Xquery



Declare @x xml;
Set @x = (Select valuefrom sometable)

Select @x.query('/Entries/Entry/')

No comments:

Post a Comment