title: Converting XML data to CSV powershell
body: <p>Hello I am new to Powershell but I have looked all over for an answer to this question, how do I convert XML data to CSV data in power shell.</p>
  
  <p>My XML data looks like this:</p>
  
  <pre><code>&lt;SolarWinds_SwitchPortMap Layer2Device="&lt;info&gt;"&gt;
       &lt;Interfaces&gt;
             &lt;Interface ifIndex="&lt;data&gt;" CollectionTime="&lt;data&gt;" ConnectorPresent="&lt;data&gt;" Duplex="&lt;data&gt;" HardwareType="&lt;data&gt;" ifAdminStatus="&lt;data&gt;" ifAdminStatustest="&lt;data&gt;" ifAlias="&lt;data&gt;" ifDescr="&lt;data&gt;" MACAddress="&lt;data&gt;" MTU="&lt;data&gt;" ifName="&lt;data&gt;" ifOperStatus="&lt;data&gt;" ifSpeed="&lt;data&gt;" ifType="&lt;data&gt;" ifTypeName="&lt;data&gt;" InBitsSec="&lt;data&gt;" InPktsSec="&lt;data&gt;" LastChange="&lt;data&gt;" LastPacketIn="&lt;data&gt;" LastPacketOut="&lt;data&gt;" ModulePortIndex="&lt;data&gt;" OutBitsSec="&lt;data&gt;" OutPktSec="&lt;data&gt;" Port="&lt;data&gt;" TrunkPort="&lt;data&gt;" /&gt;
       &lt;/Interfaces&gt;
  &lt;/Solarwinds_SwitchPortMap&gt;
  </code></pre>
  
  <p>I can't seem to get Powershell to understand the xml data,</p>
  
  <pre><code>set-location "&lt;program location&gt;"
  .\swspmcmd.exe &lt;info&gt; /xml &gt; "&lt;output_location&gt;\output_data.txt"
  get-content "&lt;output location&gt;\output_data.txt" | select -skip 17 | set-content "&lt;xmldata_location&gt;\xmldata.xml"
  $xml = [xml] (Get-Content "&lt;xmldata_location&gt;\xmldata.xml")
  
  $xml | convertto-csv -Delimiter:"," -NoTypeInformation
  </code></pre>
  
  <p>And it will only return
  "SolarWinds_SwitchPortMap"
  "System.Xml.XmlElement"</p>
  
  <p>and I don't understand why, any help is greatly appreciated thanks :).</p>