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

Drupal - Webforms as Block - Modifying Action

drupal drupal-webform

I am using Drupal 7.15, and have a Webform setup as a block that gets included on the Contact page (a basic page). The basic Contact page has editable sidebar content and then the Webform block as...

PHP - How to Check if Anchor Tag is Empty?

php jquery preg-replace anchor

How can I check if an anchor tag is empty with PHP or preg_match or JQuery? For example if an achor tag looks like: &lt;a href="some_url"&gt;&lt;/a&gt; I want to skip over it.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.