Get elements of same name from XML using XQuery in SQL server

I am having following XML

SET @RuleXML = '<questionnaire xmlns:xsi="http://schema1" xmlns:xsd="" xmlns="http://schem2" title="Sample">
    <section id="24" title="Section Title" help="" url="">
      <questions />
    <section id="23" title="Information" help="" url="">
      <questions />
    <section id="25" title="Section Title1" help="" url="">
        <question id="3" title="Question Text">
          <display-rules />
          <questions />
        <question id="4" title="Question Text" >
          <response-set type="inline" />
          <display-rules />
          <questions />

How to get a table with question id and title from all the question nodes regardless of their level using XQUERY in SQL server?


; with  xmlnamespaces (default 'http://schem2')
select  tbl.col1.value('@id', 'int')
,       tbl.col1.value('@title', 'varchar(100)')
from    @RuleXML.nodes('//question') tbl(col1)

Working example at SQL FIddle.

Need Your Help

Change URL Routing in Angularjs


I am Working On AngularJs, If I Type On Browser like

Ctype casting to Decimal returning negative value casting decimal type-conversion ctype

I am wondering if this is a bug. Can't understand why would CType work this way...!