SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


XML with NameSpaces in each Node.


XML with NameSpaces in each Node.

Author
Message
krishnasavalia
krishnasavalia
SSC Rookie
SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)SSC Rookie (40 reputation)

Group: General Forum Members
Points: 40 Visits: 140
HI Guys,

I came to a situation where I have to load XML file in SQL server tables. I have worked in past to load XML using node method but It was without namespace. Please help me. Below is my XML.


<ns1Tongueost xmlns:ns1="DataFor">
<ApplicantEntryComplete>false</ApplicantEntryComplete>
<AssistantUnderwriter>davisg</AssistantUnderwriter>
<CATTIV_USD>0</CATTIV_USD>
<CreateApplication>IIF</CreateApplication>
<ns1:Brokerage xmlns:ns1="DataFor">
<AddressLine1>5605 Glenridge Dr NE</AddressLine1>
<AddressLine2>One Premier Plaza, Ste 300</AddressLine2>
<numberOfEmployees>0</numberOfEmployees>
<ns1:Contact xmlns:ns1="DataFor">
<AddressLine1>5605 Glenridge Dr NE</AddressLine1>
<AddressLine2>One Premier Plaza, Ste 300</AddressLine2>
<BusinessAffiliation>McGriff, Seibels & Williams</BusinessAffiliation>
<Salutation>Mr.</Salutation>
<pxCreateOperator>VimalrajM</pxCreateOperator>
</ns1:Contact>
</ns1:Brokerage>
<ns1Tongueolicy xmlns:ns1="DataFor">
<SLADate>2013-05-24</SLADate>
<SLADatePol>2013-03-06</SLADatePol>
<SLADateRen>2013-03-06</SLADateRen>
</ns1Tongueolicy>
<ns1Tongueost xmlns:ns1="DataFor">
<CompletionStatus>Complete</CompletionStatus>
<PlacementType>W</PlacementType>
<ProductClass>Excess</ProductClass>
<StatusDate>2013-03-01</StatusDate>
<PostDate>2013-03-01T05:00:00.000Z</PostDate>
<PostID>DX7430701S</PostID>
<PostStatus>Converted</PostStatus>
</ns1Tongueost>
</ns1Tongueost>
wolfkillj
wolfkillj
Hall of Fame
Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)Hall of Fame (4K reputation)

Group: General Forum Members
Points: 3974 Visits: 2582
krishnasavalia (3/10/2013)
HI Guys,

I came to a situation where I have to load XML file in SQL server tables. I have worked in past to load XML using node method but It was without namespace. Please help me. Below is my XML.


<ns1Tongueost xmlns:ns1="DataFor">
<ApplicantEntryComplete>false</ApplicantEntryComplete>
<AssistantUnderwriter>davisg</AssistantUnderwriter>
<CATTIV_USD>0</CATTIV_USD>
<CreateApplication>IIF</CreateApplication>
<ns1:Brokerage xmlns:ns1="DataFor">
<AddressLine1>5605 Glenridge Dr NE</AddressLine1>
<AddressLine2>One Premier Plaza, Ste 300</AddressLine2>
<numberOfEmployees>0</numberOfEmployees>
<ns1:Contact xmlns:ns1="DataFor">
<AddressLine1>5605 Glenridge Dr NE</AddressLine1>
<AddressLine2>One Premier Plaza, Ste 300</AddressLine2>
<BusinessAffiliation>McGriff, Seibels & Williams</BusinessAffiliation>
<Salutation>Mr.</Salutation>
<pxCreateOperator>VimalrajM</pxCreateOperator>
</ns1:Contact>
</ns1:Brokerage>
<ns1Tongueolicy xmlns:ns1="DataFor">
<SLADate>2013-05-24</SLADate>
<SLADatePol>2013-03-06</SLADatePol>
<SLADateRen>2013-03-06</SLADateRen>
</ns1Tongueolicy>
<ns1Tongueost xmlns:ns1="DataFor">
<CompletionStatus>Complete</CompletionStatus>
<PlacementType>W</PlacementType>
<ProductClass>Excess</ProductClass>
<StatusDate>2013-03-01</StatusDate>
<PostDate>2013-03-01T05:00:00.000Z</PostDate>
<PostID>DX7430701S</PostID>
<PostStatus>Converted</PostStatus>
</ns1Tongueost>
</ns1Tongueost>






SQL Server supports XML namespaces. To shred your XML with the nodes() method, just include the namespace declaration in the XQuery argument and use the namespace prefix in the XQuery path, like this example from Books Online :

SELECT C.query('.') as result
FROM Production.ProductModel
CROSS APPLY Instructions.nodes('
declare namespace MI="http://schemas.microsoft.com/sqlserver/2004/07/adventure-works/ProductModelManuInstructions";
/MI:root/MI:Location') as T(C)
WHERE ProductModelID=7

Jason Wolfkill
Blog: SQLSouth
Twitter: @SQLSouth
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search