Nested XML Powershell Nested XML Powershell powershell powershell

Nested XML Powershell


The reason is that you're using the InnerXml property on the line before, which returns a string. If you just remove the get_InnerXml() call on the line above it should work just fine. On the other hand, you could work with a simpler syntax in PowerShell, if you want to. Just as a sample of the different syntax:

[xml]$xml = Get-Content .\data.xml$webApplications = $xml.WebApplications.WebApplicationforeach ($application in $webApplications){    $webAppId = $application.id    $expected = $application.expected    foreach ($siteCollection in $application.SiteCollections.SiteCollection)    {        foreach($site in $siteCollection.Site)        {        }    }}