我有一个XML文件,可以从客户端获取。我想做的是,只想将XML文件转换为数据集或数据表,并进行一些修改,然后将修改后的数据上传到我的mysql数据库中
下面是我得到的Xml格式
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>Medgate</Author>
<LastAuthor>XXXX</LastAuthor>
<Created>XXXX</Created>
<LastSaved>XXXX</LastSaved>
<Company>Medgate</Company>
<Version>16.00</Version>
</DocumentProperties>
<CustomDocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_Enabled dt:dt="string">True</MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_Enabled>
<MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_SiteId dt:dt="string">ceb177bf-013b-49ab-8a9c-4abce32afc1e</MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_SiteId>
<MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_Owner dt:dt="string">XXXX</MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_Owner>
<MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_SetDate dt:dt="string">XXXX</MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_SetDate>
<MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_Name dt:dt="string">XXXX</MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_Name>
<MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_Application dt:dt="string">Microsoft Azure Information Protection</MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_Application>
<MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_Extended_MSFT_Method
dt:dt="string">Automatic</MSIP_Label_fb5e2db6-eecf-4aa2-8fc3-174bf94bce19_Extended_MSFT_Method>
<Sensitivity dt:dt="string">XXXX</Sensitivity>
</CustomDocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>6380</WindowHeight>
<WindowWidth>19200</WindowWidth>
<WindowTopX>0</WindowTopX>
<WindowTopY>0</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Arial"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s62">
<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="8" ss:Bold="1"/>
<Interior ss:Color="#C0C0C0" ss:Pattern="Solid"/>
</Style>
<Style ss:ID="s63">
<Font ss:FontName="Arial" x:Family="Swiss" ss:Size="8"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="43" ss:ExpandedRowCount="24" x:FullColumns="1"
x:FullRows="1" ss:DefaultRowHeight="12.5">
<Column ss:Width="150" ss:Span="42"/>
<Row ss:Height="10.5" ss:StyleID="s62">
<Cell><Data ss:Type="String">Safety Incident General Incident Number</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Incident Date</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Short Description</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident What Happened</Data></Cell>
<Cell><Data ss:Type="String">Incident Classification Category Description</Data></Cell>
<Cell><Data ss:Type="String">Injury Case No</Data></Cell>
<Cell><Data ss:Type="String">Injury OSHARecordable</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Admin Unit Code Code</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Admin Unit Code Description</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Business Center Code</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Business Center Description</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Establishment Id Code</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Establishment Id Description</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Location Code</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Location Description</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident GL Expense Code</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident GL Expense Description</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Supervisor Completed Full Name And Number</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Manager Full Name And Number</Data></Cell>
<Cell><Data ss:Type="String">Supporting Factor</Data></Cell>
<Cell><Data ss:Type="String">Incident Activity</Data></Cell>
<Cell><Data ss:Type="String">Location Type</Data></Cell>
<Cell><Data ss:Type="String">Is Significant</Data></Cell>
<Cell><Data ss:Type="String">Time on Job (Incident)</Data></Cell>
<Cell><Data ss:Type="String">Person Involved</Data></Cell>
<Cell><Data ss:Type="String">Injured Employee Full Name And Number</Data></Cell>
<Cell><Data ss:Type="String">POBNature Case Master Employee Employee Type Description</Data></Cell>
<Cell><Data ss:Type="String">Injured Employee Date Of Hire</Data></Cell>
<Cell><Data ss:Type="String">Injured Employee Shift Code Description</Data></Cell>
<Cell><Data ss:Type="String">Injured Employee Part Of Body Description</Data></Cell>
<Cell><Data ss:Type="String">Injured Employee Side Of Body Description</Data></Cell>
<Cell><Data ss:Type="String">Injured Employee Nature Of Injury Description</Data></Cell>
<Cell><Data ss:Type="String">Injury Ergonomic</Data></Cell>
<Cell><Data ss:Type="String">Injury Classification</Data></Cell>
<Cell><Data ss:Type="String">Injury Source Of Injury</Data></Cell>
<Cell><Data ss:Type="String">Injury Accident Type</Data></Cell>
<Cell><Data ss:Type="String">Employee Time On Job</Data></Cell>
<Cell><Data ss:Type="String">Safety Incident Incident Time</Data></Cell>
<Cell><Data ss:Type="String">Did the incident occur while the employee was working overtime?</Data></Cell>
<Cell><Data ss:Type="String">Did the injury occur while the employee was working overtime?</Data></Cell>
<Cell><Data ss:Type="String">Lost Days (as of Previous Day to Report Run Date)</Data></Cell>
<Cell><Data ss:Type="String">Restricted Days (as of Previous Day to Report Run Date)</Data></Cell>
<Cell><Data ss:Type="String">Incident Classification Risk Description</Data></Cell>
</Row>
<Row ss:Height="10" ss:StyleID="s63">
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
</Row>
<Row ss:Height="10" ss:StyleID="s63">
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
</Row>
<Row ss:Height="10" ss:StyleID="s63">
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
<Cell><Data ss:Type="String">XXXX</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Footer x:Data="&L&1#&"Calibri"&10 xxx"/>
</PageSetup>
<Print>
<ValidPrinterInfo/>
<HorizontalResolution>600</HorizontalResolution>
<VerticalResolution>600</VerticalResolution>
</Print>
<Selected/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
我已经尝试过了
公共System.Data.DataTable CreateDataTableFromXml(字符串XmlFile) {
System.Data.DataTable Dt = new System.Data.DataTable();
try
{
DataSet ds = new DataSet();
ds.ReadXml(XmlFile);
Dt.Load(ds.CreateDataReader());
}
catch (Exception ex)
{
}
return Dt;
}
当我调试上述代码时,数据集会像每个标签数据一样单独显示,例如文档属性,单元格,数据。
我只想要表格式的数据,例如带有标题的列和带有数据的行
如果我以表格格式获取数据。我可以根据实际需要将数据处理到mysql