本文介绍了如何将此XML读入SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 有人可以告诉我(示例代码)如何将此XML读入SQL DB吗? 我应该使用LINQ to XML吗? 有没有人有任何示例代码?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? <?xml version =" 1.0" encoding =" utf-8"?> <?xml version="1.0" encoding="utf-8"?>< ReadOrderResponseType xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd =" http://www.w3.org/2001/XMLSchema"> <ReadOrderResponseType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> < ;状态xmlns =" urn:mysol:apis">成功< /状态> <Status xmlns="urn:mysol:apis">Success</Status> < TimeStamp xmlns =" urn:mysol:apis"> 2010-07-25T15:26:49.1150235Z< / TimeStamp> <TimeStamp xmlns="urn:mysol:apis">2010-07-25T15:26:49.1150235Z</TimeStamp> < StoreUrl xmlns =" urn:mysol:apis"> http://xyz.COM< / StoreUrl> <StoreUrl xmlns="urn:mysol:apis">http://xyz.COM</StoreUrl> < PageResponse xmlns =" urn:mysol:apis"> <PageResponse xmlns="urn:mysol:apis"> < Page> ; 1< / page> <Page>1</Page> <尺寸> 10< /尺寸> <Size>10</Size> < TotalSize> 18033< / TotalSize> <TotalSize>18033</TotalSize> < HasMore> true< / HasMore> <HasMore>true</HasMore> < / PageResponse> </PageResponse> < OrderList OrderId =" 20147184" ORDERNUMBER = QUOT; 20100560" xmlns =" urn:mysol:apis"> <OrderList OrderId="20147184" OrderNumber="20100560" xmlns="urn:mysol:apis"> < Archived> false< / Archived> <Archived>false</Archived> < CreateDate> 2010-07-25T01:37:04.067Z< / CreateDate> <CreateDate>2010-07-25T01:37:04.067Z</CreateDate> < ReferURL> http://www.ccc.com/Electronics/Landing1836a82496.html< / ReferURL> <ReferringURL>http://www.ccc.com/Electronics/Landing1836a82496.html</ReferringURL> < Customer> <Customer> < Browser> Mozilla / 4.0(兼容; 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> <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> <已注册> false< /已注册> <Registered>false</Registered> < IpAddress> 98.555.555.555< / IpAddress> <IpAddress>98.555.555.555</IpAddress> < EmailAddress> [email protected]< / EmailAddress> <EmailAddress>[email protected]</EmailAddress> < NonTaxable> false< / NonTaxable> <NonTaxable>false</NonTaxable> < BillingAddress> <BillingAddress> < FirstName> John< / FirstName> <FirstName>John</FirstName> < LastName> Doe< / LastName> <LastName>Doe</LastName> <地址1> 222 Adane Road< / Address1> <Address1>222 Adane Road</Address1> < City> MyCity< / City> <City>MyCity</City> < StateProvince> PA< / StateProvince> <StateProvince>PA</StateProvince> < PostalCode> 15001< / PostalCode> <PostalCode>15001</PostalCode> < ;国家>美国< /国家> <Country>US</Country> <电话> 7245550000< /电话> <Phone>7245550000</Phone> < / BillingAddress> </BillingAddress> < ShippingAddress&克t; <ShippingAddress> < FirstName> John< / FirstName> <FirstName>John</FirstName> < LastName> Doe< / LastName> <LastName>Doe</LastName> <地址1> 222 Adane Road< / Address1> <Address1>222 Adane Road</Address1> < City> MyCity< / City> <City>MyCity</City> < StateProvince> PA< / StateProvince> <StateProvince>PA</StateProvince> < PostalCode> 15001< / PostalCode> <PostalCode>15001</PostalCode> < Country> ;美国< / Country> <Country>US</Country> <电话> 7245550000< /电话> <Phone>7245550000</Phone> < / ShippingAddress> </ShippingAddress> < / Customer> </Customer> < Invoice> <Invoice> <小计货币=" USD& "> 11.99< /小计> <Subtotal Currency="USD">11.99</Subtotal> < Shipping Currency =" USD"> 8.49< ; /运输> <Shipping Currency="USD">8.49</Shipping> <总货币=" USD"> 20.48< /总计> <Total Currency="USD">20.48</Total> < CombineHandling> true< / CombineHandling> <CombineHandling>true</CombineHandling> < Weight UnitOfMeasure =" Imperial"> <Weight UnitOfMeasure="Imperial"> < ; Major> 3< / Major> <Major>3</Major> < Minor> 0.00< / Minor> <Minor>0.00</Minor> < / Weight> </Weight> < LineItemList LineItemId =" 80927"> <LineItemList LineItemId="80927"> < FreeShipping> false< / FreeShipping> ; <FreeShipping>false</FreeShipping> <名称> OEM标准电池< /名称> <Name>OEM Standard battery</Name> < NonTaxable> false< / NonTaxable> <NonTaxable>false</NonTaxable> < PartNumber> AB463446FZ< ; / PartNumber> <PartNumber>AB463446FZ</PartNumber> < ProductId> 82496< / ProductId> <ProductId>82496</ProductId> < ProductClass> Regular< / ProductClass> <ProductClass>Regular</ProductClass> < QtySold> 1< / QtySold> <QtySold>1</QtySold> < Weight UnitOfMeasure =" Imperial"> <Weight UnitOfMeasure="Imperial"> < Major> 3< / Major> <Major>3</Major> < Minor> 0.00< / Minor> <Minor>0.00</Minor> < / Weight> </Weight> < UnitPrice Currency =" USD"> 11.99< / UnitPrice> <UnitPrice Currency="USD">11.99</UnitPrice> < ShippingOption> Shippable< / ShippingOption> <ShippingOption>Shippable</ShippingOption> < / LineItemList> </LineItemList> < / Invoice> </Invoice> < Payment> <Payment> < AuthorizationId> 248459< / AuthorizationId> <AuthorizationId>248459</AuthorizationId> < TransactionId> 3100095455< / TransactionId> <TransactionId>3100095455</TransactionId> < CreditCard> <CreditCard> < Expiration> 2012-05-01< / Expiration> <Expiration>2012-05-01</Expiration> < FirstName> ; John< / FirstName> <FirstName>John</FirstName> < LastName> Doe< / LastName> <LastName>Doe</LastName> < Number> 3333< / Number> <Number>3333</Number> < Issuer> AmericanExpress< / Issuer> <Issuer>AmericanExpress</Issuer> < Verification> <Verification> <卡>匹配< /卡> <Card>Match</Card> < PostalCode>匹配< / PostalCode> <PostalCode>Match</PostalCode> < Street>匹配< / Street> <Street>Match</Street> < / Verification> </Verification> < / CreditCard> </CreditCard> < PaymentMethod> AuthorizeNet< / PaymentMethod> <PaymentMethod>AuthorizeNet</PaymentMethod> < / Payment> </Payment> < Shipping> ; <Shipping> <名称>地面服务< /名称> <Name>Ground Service</Name> < Carrier> Customer< / Carrier> <Carrier>Customer</Carrier> < / Shipping> </Shipping> < Status OrderStatusId =" 1"> <Status OrderStatusId="1"> <名称>订单重新ceived< / Name> <Name>Order Received</Name> < / Status> </Status> < QuestionList> <QuestionList> < Title> Check box to blind drop-ship< / title> <Title>Check box to blind drop-ship</Title> < Display> CheckBoxList< / Display> <Display>CheckBoxList</Display> < BooleanAnswerList> <BooleanAnswerList> <答案>订单将从结算名称& amp; amp;地址。不包括滑动。< / Answer> <Answer>Order will be shipped as arriving from billing name & address. Slip will not be included.</Answer> < Value> false< / Value> <Value>false</Value> < / BooleanAnswerList> </BooleanAnswerList> < / QuestionList> </QuestionList> < QuestionList> <QuestionList> < Title> sales person intial< / title> <Title>sales person intial</Title> <显示> TextList< /显示> <Display>TextList</Display> < TextAnswerList /> <TextAnswerList /> < / QuestionList> </QuestionList> < / OrderList> </OrderList>< / ReadOrderResponseType> </ReadOrderResponseType> 推荐答案 您使用的是哪种语言?What language are you using?您是否将XML存储在一个XML字段中数据库?或者在表格的单独字段中?Are you storing the XML in one XML field in the database? Or in separate fields in the table? Linq to XML用于处理XML,例如导航或搜索特定节点。Linq to XML is for working with the XML, such as navigation or searching for specific nodes.这里是一些Linq to XML的链接:Here is a link to some Linq to XML: http:// msdn.microsoft.com/en-us/library/bb387098.aspx 希望这会有所帮助。 这篇关于如何将此XML读入SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-29 21:44