How can I read value from this xml


I have a xml

 < p1:Attribute xmlns:p1="urn:oasis:names:tc:SAML:1.0:assertion" AttributeName="Priority"     AttributeNamespace="RequestInfo">  
   <p1:AttributeValue>Medium< /p1:AttributeValue>
 < /p1:Attribute>

please remove spaces I added after '<' in above xml

How can I read value of of < p1:AttributeValue> from this xml in sql server

Thanks in Advance

Sumit Jain

more ▼

asked Sep 09, 2011 at 01:44 AM in Default

avatar image

21 1 1 1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first
 declare @xml xml
 set @xml = '<p1:Attribute xmlns:p1="urn:oasis:names:tc:SAML:1.0:assertion" AttributeName="Priority"     AttributeNamespace="RequestInfo">

 XMLNAMESPACES('urn:oasis:names:tc:SAML:1.0:assertion' AS ns1)
 SELECT @xml.query('//ns1:Attribute').value('(/ns1:Attribute)[1]','varchar(max)') 
 AS AttributeValue
more ▼

answered Sep 09, 2011 at 03:50 AM

avatar image

Kev Riley ♦♦
66.8k 48 65 81

Thanks Kev

Sep 09, 2011 at 08:26 AM sumitjainam

AWESOME!!! Been looking to figure this out, at times, for over a year! Thanks so much!!

Dec 22, 2011 at 09:55 AM captainks
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Sep 09, 2011 at 01:44 AM

Seen: 998 times

Last Updated: Sep 09, 2011 at 02:02 AM

Copyright 2018 Redgate Software. Privacy Policy