在PowerShell中将XML元素转换为逗号分隔的字符串

时间:2017-08-11 17:47:49

标签: xml powershell delimiter

我的XML文件中包含以下元素:

    <Applications>
        <Application>Base Operations</Application> 
         <Application>Development Screen</Application> 
         <Application>eStat</Application> 
         <Application>EStat Rate Quote Poller</Application> 
         <Application>ETA Alert Agent</Application> 
         <Application>File Maintenance</Application> 
         <Application>Fuel Optimization Agent</Application> 
         <Application>FuelSourcingModule</Application> 
         <Application>Operations Reporting</Application> 
         <Application>Order Entry</Application> 
         <Application>PB GP Stand Alone</Application> 
         <Application>PB Rating Engine</Application> 
         <Application>PS Scheduler</Application> 
         <Application>Reports</Application> 
         <Application>Settlements</Application> 
         <Application>System Administration</Application> 
         <Application>TMW Backoffice</Application> 
         <Application>TMW CRM Right</Application> 
         <Application>TMW Operations</Application> 
    </Applications>

如何将每个转换为如下所示的列表:Base Operations, Development Screen, eStat, etc.

1 个答案:

答案 0 :(得分:1)

这个怎么样?

[XML]$xml = @"
<Applications>
        <Application>Base Operations</Application> 
         <Application>Development Screen</Application> 
         <Application>eStat</Application> 
         <Application>EStat Rate Quote Poller</Application> 
         <Application>ETA Alert Agent</Application> 
         <Application>File Maintenance</Application> 
         <Application>Fuel Optimization Agent</Application> 
         <Application>FuelSourcingModule</Application> 
         <Application>Operations Reporting</Application> 
         <Application>Order Entry</Application> 
         <Application>PB GP Stand Alone</Application> 
         <Application>PB Rating Engine</Application> 
         <Application>PS Scheduler</Application> 
         <Application>Reports</Application> 
         <Application>Settlements</Application> 
         <Application>System Administration</Application> 
         <Application>TMW Backoffice</Application> 
         <Application>TMW CRM Right</Application> 
         <Application>TMW Operations</Application> 
    </Applications>
"@

[String]::Join(",",$xml.Applications.Application)