简体   繁体   中英

Linq to XML, C#

I have a multilevel xml that i receive from queues. I need to break each level and put into database. Below is the example:

<?xml version="1.0" encoding="utf-16"?>
   <Request>
     <transactionID>3</transactionID>
       <units>
         <Number>001</serialNumber>
         <Id>222</instanceId>
         <fNumber>765</routeNumber>
         <status>open</status>
         <Message>Error</errorMessage>
       </units>
       <units>
         <Number>009</serialNumber>
         <Id>675</instanceId>
         <fNumber>765</routeNumber>
         <status>Close</status>
         <Message>mesage</errorMessage>
       </units>
     </Request>

I tried using ds.ReadXML... it only takes units beceause i give datamember property of datagrid to units

i need to put units into different table and transaction id also.. Pls help.

If

You can use Linq to XML to navigate through the XML and break it down or you might Deserialize the XML into a C# object Have a look at

Deserializing XML to Objects in C#

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM