所以我现在正在尝试创建一个从excel文件导入数据然后将其转换为XML的应用程序。我的代码(C#)的基本流程是将excel文件中的数据导入dataTable - > dataSet然后使用DataSet.GetXml方法将其转换为XML。由于我从excel文件的第1行(标题)中获取XML的标记,因此我的XML输出现在看起来像这样:
<practitionerGroup>
<practitionerDesignation>MD</practitionerDesignation>
<firstName>JOHN</firstName>
<middleInitial />
<lastName>DOE</lastName>
<addressLine1>1532 N 7TH ST</addressLine1>
<addressLine2>STE 156</addressLine2>
<city>TERRE HAUTE</city>
<state>IN</state>
<zip>47807</zip>
<ZIP_TEXT>47807</ZIP_TEXT>
<tradeNameDosage>EstroGel 0.06%</tradeNameDosage>
<pkgSize>50g in 1 Bottle Pump</pkgSize>
<pkgQtyReq>10</pkgQtyReq>
<pkgQtyDist>10</pkgQtyDist>
<hasReqSignature>Y</hasReqSignature>
<hasReceiptSignature>Y</hasReceiptSignature>
</practitionerGroup>
但是,我需要将XML标记看起来像这样:
<practitionerGroup>
<practitioner>
<practitionerDesignation>NP</practitionerDesignation>
<person>
<firstName>JANE</firstName>
<lastName>DOE</lastName>
<middleInitial></middleInitial>
</person>
<personAddress>
<addressLine1>2741 DEBARR ROAD</addressLine1>
<addressLine2>STE 312</addressLine2>
<city>ANCHORAGE</city>
<state>AK</state>
<zip>99508</zip>
</personAddress>
</practitioner>
<tradeNameDosage>EstroGel 50g Starter Unit</tradeNameDosage>
<pkgSize>50g in 1 Bottle Pump</pkgSize>
<pkgQtyReq>5</pkgQtyReq>
<hasReqSignature>Y</hasReqSignature>
<pkgQtyDist>5</pkgQtyDist>
<hasReceiptSignature>Y</hasReceiptSignature>
</practitionerGroup>
修改XML标记格式的最佳方法是什么? 感谢。