【问题标题】:Parsing through XML and dump values into Excel using UIPATH使用 UIPATH 解析 XML 并将值转储到 Excel
【发布时间】:2020-01-25 14:49:55
【问题描述】:

我想只转储 BMW 汽车的数据以使其表现出色。我确实有数千个 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>

**输出 - **

【问题讨论】:

    标签: xml xml-parsing xml-deserialization uipath


    【解决方案1】:

    嗯,有几种可能的方法,您选择哪一种取决于您对 .NET 的熟悉程度(使用 XDocument 类,UiPath KB here 中的更多详细信息)。

    如果您想避免这种情况,可以尝试仅使用 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
    

    【讨论】:

      猜你喜欢
      • 2012-11-13
      • 2021-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-15
      • 1970-01-01
      相关资源
      最近更新 更多