How to read XML into SQL - LINQ

VB.NET , LINQ , XML Houston, United States
  • 10 years ago

    Can someone please tell me (sample code) how to read this XML into a SQL DB? Should I use LINQ to XML? Does anyone have any sample code? I am using VB.NET

    <Status xmlns="urn:mysol:apis">Success</Status>
    
    <TimeStamp xmlns="urn:mysol:apis">2010-07-25T15:26:49.1150235Z</TimeStamp>
    
    <StoreUrl xmlns="urn:mysol:apis">http://xyz.COM</StoreUrl>
    
    <PageResponse xmlns="urn:mysol:apis">
    
    	<Page>1</Page>
    
    	<Size>10</Size>
    
    	<TotalSize>18033</TotalSize>
    
    	<HasMore>true</HasMore>
    
    </PageResponse>
    
    <OrderList OrderId="20147184" OrderNumber="20100560" xmlns="urn:mysol:apis">
    
    	<Archived>false</Archived>
    
    	<CreateDate>2010-07-25T01:37:04.067Z</CreateDate>
    
    	<ReferringURL>http://www.ccc.com/Electronics/Landing1836a82496.html</ReferringURL>
    
    	<Customer>
    
    		<Browser>Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)</Browser>
    
    		<Registered>false</Registered>
    
    		<IpAddress>98.555.555.555</IpAddress>
    
    		<EmailAddress>[email protected]</EmailAddress>
    
    		<NonTaxable>false</NonTaxable>
    
    		<BillingAddress>
    
    			<FirstName>John</FirstName>
    
    			<LastName>Doe</LastName>
    
    			<Address1>222 Adane Road</Address1>
    
    			<City>MyCity</City>
    
    			<StateProvince>PA</StateProvince>
    
    			<PostalCode>15001</PostalCode>
    
    			<Country>US</Country>
    
    			<Phone>7245550000</Phone>
    
    		</BillingAddress>
    
    		<ShippingAddress>
    
    			<FirstName>John</FirstName>
    
    			<LastName>Doe</LastName>
    
    			<Address1>222 Adane Road</Address1>
    
    			<City>MyCity</City>
    
    			<StateProvince>PA</StateProvince>
    
    			<PostalCode>15001</PostalCode>
    
    			<Country>US</Country>
    
    			<Phone>7245550000</Phone>
    
    		</ShippingAddress>
    
    	</Customer>
    
    	<Invoice>
    
    		<Subtotal Currency="USD">11.99</Subtotal>
    
    		<Shipping Currency="USD">8.49</Shipping>
    
    		<Total Currency="USD">20.48</Total>
    
    		<CombineHandling>true</CombineHandling>
    
    		<Weight UnitOfMeasure="Imperial">
    
    			<Major>3</Major>
    
    			<Minor>0.00</Minor>
    
    		</Weight>
    
    		<LineItemList LineItemId="80927">
    
    			<FreeShipping>false</FreeShipping>
    
    			<Name>OEM Standard battery</Name>
    
    			<NonTaxable>false</NonTaxable>
    
    			<PartNumber>AB463446FZ</PartNumber>
    
    			<ProductId>82496</ProductId>
    
    			<ProductClass>Regular</ProductClass>
    
    			<QtySold>1</QtySold>
    
    			<Weight UnitOfMeasure="Imperial">
    
    				<Major>3</Major>
    
    				<Minor>0.00</Minor>
    
    			</Weight>
    
    			<UnitPrice Currency="USD">11.99</UnitPrice>
    
    			<ShippingOption>Shippable</ShippingOption>
    
    		</LineItemList>
    
    	</Invoice>
    
    	<Payment>
    
    		<AuthorizationId>248459</AuthorizationId>
    
    		<TransactionId>3100095455</TransactionId>
    
    		<CreditCard>
    
    			<Expiration>2012-05-01</Expiration>
    
    			<FirstName>John</FirstName>
    
    			<LastName>Doe</LastName>
    
    			<Number>3333</Number>
    
    			<Issuer>AmericanExpress</Issuer>
    
    			<Verification>
    
    				<Card>Match</Card>
    
    				<PostalCode>Match</PostalCode>
    
    				<Street>Match</Street>
    
    			</Verification>
    
    		</CreditCard>
    
    		<PaymentMethod>AuthorizeNet
    

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“An expert is a man who has made all the mistakes that can be made in a very narrow field” - Niels Bohr