title: XML Parsing from a response of Invoke-WebRequest
body: <p>I am trying to parse a specific value from a response to an <code>Invoke-WebRequest</code> I have made in a PowerShell script, but I am not able to get it.</p>
  
  <p>If I used postman for example to get the content I would get the below:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;globalInfo&gt;
      &lt;currentLoggedInUser&gt;admin&lt;/currentLoggedInUser&gt;
      &lt;versionInfo&gt;
          &lt;majorVersion&gt;6&lt;/majorVersion&gt;
          &lt;minorVersion&gt;2&lt;/minorVersion&gt;
          &lt;patchVersion&gt;4&lt;/patchVersion&gt;
          &lt;buildNumber&gt;4292526&lt;/buildNumber&gt;  &lt;!-- this is what I need --&gt;
      &lt;/versionInfo&gt;
  &lt;/globalInfo&gt;
  </code></pre>
  
  <p>Below is the command I am using within the script and I get nothing:</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$r = Invoke-WebRequest -Uri "$uriP/api/1.0/appliance-management/global/info" -Body $body -Method:Get -Headers $head -ContentType "application/xml" -ErrorAction:Stop -TimeoutSec 60
  $bn = ($r.Content.globalInfo.versionInfo.buildNumber)
  </code></pre>
  
  <p>Also, if I used <code>$bn = ($r.Content)</code> I will get the full content like below:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;globalInfo&gt;&lt;currentLoggedInUser&gt;admin&lt;/currentLoggedInUser&gt;&lt;versionInfo&gt;&lt;majorVersion&gt;6&lt;/majorVersion&gt;&lt;minorVersion&gt;2&lt;/minorVersion&gt;&lt;patchVersion&gt;4&lt;/patch
  Version&gt;&lt;buildNumber&gt;4292526&lt;/buildNumber&gt;&lt;/versionInfo&gt;&lt;/globalInfo&gt;
  </code></pre>
  
  <p>I can see the format of the response from the postman is different from the one I get in PowerShell using only (<code>$r.Content</code>), but I am not sure what is the issue here.</p>