[英]Importing XML with multiple tables to VB.NET
所以我有以下.XML文件...
<?xml version="1.0" encoding="UTF-8"?>
<PPG>
<Header>
<Protocol>
<Message>MixDataInterface</Message>
<Name>PPG</Name>
<Version>1.3.0</Version>
</Protocol>
<Transaction>
<TransactionID>2577f125-663d-4351-909c-02fab90f21fd</TransactionID>
<TransactionDate>2016-10-13T22:48:09</TransactionDate>
</Transaction>
<ShopInfo>
<PPGShopID />
<ShopID>DB</ShopID>
<ShopName>TRAXX</ShopName>
</ShopInfo>
</Header>
<MixDataInterface>
<ROData>
<ROCount>5</ROCount>
<RepairOrders>
<RO>
<ROCounter>1</ROCounter>
<RONumber>UNASSIGNED</RONumber>
<Notes />
<Undercoat>False</Undercoat>
<Clearcoat>False</Clearcoat>
<Basecoat>True</Basecoat>
<TotalLiquidCost>0.00</TotalLiquidCost>
<TotalSundryCost>0.00</TotalSundryCost>
<MixCount>1</MixCount>
<Mixes>
<Mix>
<MixCounter>1</MixCounter>
<MixRONumber>UNASSIGNED</MixRONumber>
<MixedDate>2016-10-05T00:00:00</MixedDate>
<MixedBy />
<MixedByEmployeeID />
<MixCost>0.00</MixCost>
<PPGBrandCode>7EFBB</PPGBrandCode>
<ColorMixDescription>AQUABASE PLUS (AQU+ BC Solid) 7EFBB Prime (BIANCO BIANCO , BIANCO NEVE)</ColorMixDescription>
<FormulaType>Standard</FormulaType>
<ComponentCount>4</ComponentCount>
<Components>
<Component>
<ComponentCounter>1</ComponentCounter>
<ComponentRONumber>UNASSIGNED</ComponentRONumber>
<ComponentCode>P990-8900</ComponentCode>
<ComponentDescription>BRILLIANT WHITE</ComponentDescription>
<ComponentCost>0.00</ComponentCost>
<ComponentWeightApplied>0.00000</ComponentWeightApplied>
<ComponentWeightTarget>179.30470</ComponentWeightTarget>
<ComponentDensity>1.21300</ComponentDensity>
</Component>
</Components>
</Mix>
</Mixes>
<SundryCount>0</SundryCount>
</RO>
</RepairOrders>
</ROData>
</MixDataInterface>
</PPG>
我希望將其導入VB.NET。 我發現以下MSDN文章https://msdn.microsoft.com/zh-cn/library/ekw4dh3f.aspx,但是示例.XML文件僅包含一個表,因此將其應用於文件時會出錯。
有人可以幫我解決如何將此文件導入數據集。
稍后,我將需要弄清楚如何在更新.XML時更新數據集(我別無選擇,我唯一的數據源就是.XML),但現在我會很高興能夠導入文件。
@jdweng是正確的,這里有一些代碼可幫助您探索導入的內容:
Dim ds As New DataSet
Dim sr As New StringReader(sPostXMLData)
ds.ReadXml(sr)
For Each t As DataTable In ds.Tables
Debug.Print(t.TableName)
Next
表:頭協議交易ShopInfo MixDataInterface ROData RepairOrders RO Mixs Mix Components組件
沒用處。 查看更多用於分析數據的XML專用工具。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.