xml - 使用 UIPATH 解析 XML 并将值转储到 Excel
问题描述
我想转储只有宝马汽车的数据才能脱颖而出。我确实有数千个 XML 文件,并且许多条目会有所不同(在本例中为 3,它可以从 0 到 5)。
考虑到这种情况,我必须在 UIPATH 中增加计数器或事务项。但首先我想将这个 XML 文件的数据转储到 excel 中,我希望在附加的图像中给出输出
<country>
<state>Texas</state>
<cars>
<brand>BMW</brand>
<model>X1</model>
<unit>210000</unit>
</cars>
<cars>
<brand>BMW</brand>
<model>X6</model>
<unit>210000</unit>
</cars>
<cars>
<brand>BMW</brand>
<model>X7</model>
<unit>210000</unit>
</cars>
<cars>
<brand>Ford</brand>
<model>mustang</model>
<unit>319000</unit>
</cars>
<cars>
<brand>Volvo</brand>
<model>XC90</model>
<unit>91100</unit>
</cars>
</country>
**输出 - **
解决方案
好吧,有几种可能的方法,您选择哪一种取决于您对 .NET 的熟悉程度(使用XDocument类,此处的 UiPath KB 中有更多详细信息)。
如果您希望避免这种情况,您可以尝试仅使用该Execute XPath
函数的以下序列:
1. For each XML file
2. ... Get number of BMWs: count(//cars/brand[text()='BMW'])
3. ... Loop that amount of times
4. ... ... Get each individual value for that car: string(//cars[brand[text()='BMW']][i]/model)
... ... ... (replace the i for the loop number)
5. ... ... Write that to Excel
6. ... ... Repeat the previous command also for unit
推荐阅读
- java - 如何在这里修复 java.lang.IndexOutOfBoundsException 错误?
- r - 基于R中的列绘制堆积条
- r - 将数据从行移动到 R 中的列,忽略缺失值并根据转置列添加列
- javascript - 如何修复“用户 \'root\'@\'localhost\' 的访问被拒绝,错误号 1045
- r - 如何将 ShinyR 功能与 UI 集成?
- google-cloud-platform - 永久允许 Google Cloud SDK 访问您在 Colaboratory 的 Google 帐户
- php - 强制免费送货而不隐藏 WooCommerce 中的所有其他送货选项
- python - pytorch 计算成对差异:NumPy 与 PyTorch 和不同 PyTorch 版本的结果不正确
- javascript - 为什么这个 JavaScript 画布绘图应用程序滞后?
- solidity - 制作像SLA这样的智能合约