我有 2 个数据表 fireCollarTable_ 和 electrofusionTable_。
fireCollarTable_ = new System.Data.DataTable("Fire Collar");
fireCollarTable_.Columns.Add("Article", typeof(string));
fireCollarTable_.Columns.Add("Description", typeof(string));
fireCollarTable_.Columns.Add("Diameter", typeof(double));
electroFusionCouplerTable_ = new System.Data.DataTable("Electrofusion Coupler");
electroFusionCouplerTable_.Columns.Add("Article", typeof(string));
electroFusionCouplerTable_.Columns.Add("Description", typeof(string));
electroFusionCouplerTable_.Columns.Add("Diameter", typeof(double));
electroFusionCouplerTable_.Columns.Add("Length", typeof(double));
上面定义了两个数据表,XML文件是
<Catalogue>
<!-- 1-Item, 2-Article, 3-Description, 4-PipeType, 5-Diameter -->
<Record a1="Fire Collar" a2="VS0410001" a3="Fire Collar, 40 mm" a5="40" />
<Record a1="Fire Collar" a2="VS0410003" a3="Fire Collar, 50 mm" a5="50" />
<Record a1="Fire Collar" a2="VS0410005" a3="Fire Collar, 56 mm" a5="56" />
<!-- 1-Item, 2-Article, 3-Description, 4-PipeType, 5-Diameter,9-Length-->
<Record a1="Electrofusion Coupler" a2="VS0350001" a3="Electrofusion coupler, 40 mm" a5="40" a9="64" />
<Record a1="Electrofusion Coupler" a2="VS0350003" a3="Electrofusion coupler, 50 mm" a5="50" a9="60" />
</Catalogue>
我想解析 XML 文件并根据属性“a1”的值,我想将数据插入数据表之一。例如,如果“a1”的值 = “Fire Collar”,那么数据应该插入到 firecollar 表中。