title: PowerShell XML Multiple ChildNodes Comma Separated Strings to Array
body: <p>I have an API for a Sonus SBC that returns results in XML for analogue ports. I have three child nodes with the same number of values in each that I need to turn into an array/table. The problem is each node has a comma delimited string so I am left with three objects each containing a string like below:</p>
  <pre><code>ApplyToChannelList      1.1,1.2,1.3,1.4
  ChannelOwnNumberList    71750,51375,53004,53146
  FXSHotlineNumberList    53940,,,70309
  </code></pre>
  <p>I have tried trying to <code>ConvertFrom-String</code> but that creates three separate arrays that I can't work out how to join together.
  I have tried a <code>For-Each</code> that would not process anything and gave no result.</p>
  <ul>
  <li>I have tried splitting the strings and adding them to a custom object.</li>
  <li>I have tried splitting the strings and joining them together with commas to try and make an array.</li>
  </ul>
  <p>My guess is I need to split the strings first and then get them into a custom object using possibly nested <code>For-Each</code> but when my first <code>For-Each</code> fails it makes it tricky.</p>
  <p>To get the three nodes I need I am using the following:</p>
  <pre><code>$rest = Invoke-RestMethod -Uri $BackupUrl -Method GET -ContentType &quot;text/html;charset=UTF-8&quot; -Body $null -WebSession $ps -Verbose
  $xml = ([xml]$rest.Trim())
  $child = $xml.ChildNodes.Cassg | Select-Object ApplyToChannelList, ChannelOwnNumberList, FXSHotlineNumberList
  </code></pre>
  <p>Any suggestions or tips on what to type of commands to try is greatly appreciated.</p>
  <h3>Expected Output:</h3>
  <pre><code>ApplyToChannelList ChannelOwnNumberList FXSHotlineNumberList
  1.1                 71750               
  1.2                 51375               56072
  </code></pre>
  <h3>XML Output</h3>
  <pre><code>id                              : 20001
  href                            : https://hostname.dns/rest/cassg/20001
  ActionSetTableId                : 0
  ApplyToChannelList              : 1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.10,1.11,1.12,1.13,1.14,1.15,1.16,1.17,1.18,1.19,1.20,1.21,1.22,1.23,1.24,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,2.10,2.11,2.12,2.13,2.14,2.15,2.16,2.17,2.18,2.19,2.20
  CallForward                     : 0
  CallForwardActivate             : *72
  CallForwardDeactivate           : *73
  CallInformationFormatENM        : 0
  CallerIDType                    : 0
  CallerIdPrivacySignaling        : 
  CasEnMProfileId                 : 0
  CasLineType                     : 0
  CasLoopStartFxoProfileId        : 0
  CasLoopStartFxsProfileId        : CasLoopStartFxsProfileId
  CasR2ProfileId                  : 0
  CasSgDTMFCallerIDEndDelimiter   : 12
  CasSgDTMFCallerIDStartDelimiter : 13
  CasSgDirection                  : 2
  CasSgENMDelimiterDigit          : 15
  CasSgENMEndDigit                : 15
  CasSgENMStartDigit              : 15
  CasSgHuntMethod                 : 5
  CasSgRingbackPlayPolicy         : 0
  CasSignalingType                : 0
  CasSupplementaryProfileId       : 0
  ChannelOwnNumberList            : 71750,51375,53004,53146,53940,58940,70153,70309,71125,71681,75033,75021,75027,75015,75104,75120,75126,75145,75151,75320,75326,75351,75380,75449,52417,52895,75393,58627,53154,58473,51932,51871,53022,53595,19144,19152,19127,1
                                    9137,19101,19105,19112,19117,53410,54952
  ConfigIEState                   : 1
  Description                     : CAS FXS Analog Ports
  EndOfDialDigit                  : 
  FXSCallForwardingNumberList     : ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
  FXSHotlineNumberList            : ,,,,,,,,,,56072,56072,56072,56072,56072,,,,56072,,,,,,,,,,,,,,,,,,,,,,,,,
  NoChannelAvailableId            : 34
  RelayCallingName                : 1
  RouteTableId                    : RouteTableId
  TimerSanitySetup                : 255000
  ToneTableId                     : ToneTableId
  customAdminState                : 1
  rt_CasSgCurrentCalls            : 1
  rt_CasSgIncomingCallsAttempted  : 197
  rt_CasSgIncomingCallsConnected  : 143
  rt_CasSgOutgoingCallsAttempted  : 22
  rt_CasSgOutgoingCallsConnected  : 9
  rt_CasSignalingType             : 0
  </code></pre>