Xpath with PnP xml

Occasional Contributor

Hi, I'm trying to get all Folder-nodes from an PnP XML schema file by using XPath, but I only get empty results.

XML (sorry for the formatting):

<?xml version="1.0"?>
   <pnp:Templates ID="XXX">
      <pnp:ProvisioningTemplate ID="YYY" Version="1" BaseSiteTemplate="STS#3" Scope="Web">
         <pnp:Lists>
            <pnp:ListInstance Title="List 2" ...>
               <pnp:Folders>
                  <pnp:Folder Name="Folder 2.1" />
                  <pnp:Folder Name="Folder 2.2" >
                     <pnp:Folder Name="Folder 2.2.1" />
                     <pnp:Folder Name="Folder 2.2.1" />
                  </pnp:Folder>
               </pnp:Folders>
            </pnp:ListInstance>
         </pnp:Lists>
      </pnp:ProvisioningTemplate>
   </pnp:Templates>
</pnp:Provisioning>
 
Script:
$XPath = "//Folder"
$nodes = Select-Xml -Path $localPath -XPath $XPath

But $nodes are empty.
However, the following code works, but will only get Folder nodes directly under Folders: 
 
[xml]$xml = Get-Content $localPath
$folders = $xml.Provisioning.Templates.ProvisioningTemplate.Lists.ListInstance.Folders.Folder
 
 
0 Replies