Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 XML data extraction
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

LearningSQLKid
Yak Posting Veteran

Hong Kong
51 Posts

Posted - 05/12/2013 :  22:45:43  Show Profile  Reply with Quote
Hi Guys

I need help in extracting data but i don't know how would i use default namespaces and how to extract data from the following xml. I need value from BloodType tag



<ase:aseXML xmlns:ase="urn:aseXML:r17" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:aseXML:r17 http://www.nemmco.com.au/aseXML/schemas/r17/aseXML_r17.xsd">
<Person>
<From>xxxx</From>
<To>yyyyy</To>
<MessageID>000914566</MessageID>
<MessageDate>2010-05-21</MessageDate>
<BllodType>A</TransactionGroup>
</Person>
</ase:aseXML>


Thanks in Advance

Select Knowledge from LearningProcess

stepson
Aged Yak Warrior

Romania
545 Posts

Posted - 05/13/2013 :  01:06:47  Show Profile  Reply with Quote
Hi,

this line is correct ?
<BllodType>A</TransactionGroup>

for me, I changed to :
<BllodType>A</BllodType>





declare @xmlText as xml
set @xmlText ='
<ase:aseXML xmlns:ase="urn:aseXML:r17" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:aseXML:r17 http://www.nemmco.com.au/aseXML/schemas/r17/aseXML_r17.xsd">
 <Person>
 <From>xxxx</From>
 <To>yyyyy</To>
 <MessageID>000914566</MessageID>
 <MessageDate>2010-05-21</MessageDate>
 <BllodType>A</BllodType>
 </Person>
 </ase:aseXML>'


;WITH XMLNAMESPACES( 'urn:aseXML:r17' AS ase)


select
	t.u.value('.','nvarchar(2)')
from @xmlText.nodes('/ase:aseXML/Person/BllodType') as t(u)


Ce-am pe mine am si-n dulap, cand ma-mbrac zici ca ma mut
sabinWeb
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000