How to extract an element from an XML file?

I have the following simple XML fragment shown below. What would the T-SQL look like if I wanted to just extract the 'EntityFriendlyName' attribute?

<SimpleRuleValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <EntityId>0</EntityId>
    <EntityFriendlyName>ALine</EntityFriendlyName>
</SimpleRuleValue>

Answers


It would be something like this:

SELECT CAST(X.SomeXML AS XML).value('(SimpleRuleValue/EntityFriendlyName)[1]','nvarchar(1000)') AS EntityFriendlyName
FROM XmlSource X

Edit: A little more information.


Need Your Help

Pygame collision detect with object and rect

python pygame collision-detection

Yep, I'm asking another question about this program :D

Problem deploying Refinery CMS with Capistrano

ruby-on-rails capistrano bundler refinerycms

I have the following custom Refinery CMS engines in my gemfile:

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.