SQL Server Forums
Profile | Register | 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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

LearningSQLKid
Starting Member

Hong Kong
46 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
Constraint Violating Yak Guru

Romania
434 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  
 New 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.05 seconds. Powered By: Snitz Forums 2000