Xpath with PnP xml

%3CLINGO-SUB%20id%3D%22lingo-sub-294073%22%20slang%3D%22en-US%22%3EXpath%20with%20PnP%20xml%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-294073%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20I'm%20trying%20to%20get%20all%20Folder-nodes%20from%20an%20PnP%20XML%20schema%20file%20by%20using%20XPath%2C%20but%20I%20only%20get%20empty%20results.%3C%2FP%3E%3CP%3EXML%20(sorry%20for%20the%20formatting)%3A%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%3C%2FSPAN%3E%3CSPAN%3Exml%3C%2FSPAN%3E%3CSPAN%3E%20version%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%221.0%22%3C%2FSPAN%3E%3CSPAN%3E%3F%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Epnp%3AProvisioning%3C%2FSPAN%3E%20%3CSPAN%3Exmlns%3Apnp%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22%3CA%20href%3D%22http%3A%2F%2Fschemas.dev.office.com%2FPnP%2F2018%2F05%2FProvisioningSchema%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fschemas.dev.office.com%2FPnP%2F2018%2F05%2FProvisioningSchema%3C%2FA%3E%22%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Epnp%3ATemplates%3C%2FSPAN%3E%20%3CSPAN%3EID%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22XXX%22%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Epnp%3AProvisioningTemplate%3C%2FSPAN%3E%20%3CSPAN%3EID%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22YYY%22%3C%2FSPAN%3E%20%3CSPAN%3EVersion%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%221%22%3C%2FSPAN%3E%20%3CSPAN%3EBaseSiteTemplate%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22STS%233%22%3C%2FSPAN%3E%20%3CSPAN%3EScope%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22Web%22%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Epnp%3ALists%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Epnp%3AListInstance%3C%2FSPAN%3E%20%3CSPAN%3ETitle%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22List%202%22%3C%2FSPAN%3E%20%3CSPAN%3E...%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Epnp%3AFolders%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Epnp%3AFolder%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22Folder%202.1%22%26nbsp%3B%2F%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Epnp%3AFolder%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3EName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22Folder%202.2%22%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Epnp%3AFolder%3C%2FSPAN%3E%20%3CSPAN%3EName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22Folder%202.2.1%22%3C%2FSPAN%3E%20%3CSPAN%3E%2F%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CSPAN%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%3Epnp%3AFolder%3C%2FSPAN%3E%20%3CSPAN%3EName%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%22Folder%202.2.1%22%3C%2FSPAN%3E%20%3CSPAN%3E%2F%26gt%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%3CSPAN%3Epnp%3AFolder%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3CSPAN%3E%3CSPAN%3Epnp%3AFolders%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%3CSPAN%3Epnp%3AListInstance%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3CSPAN%3E%3CSPAN%3Epnp%3ALists%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSPAN%3E%3CSPAN%3Epnp%3AProvisioningTemplate%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%3CSPAN%3E%3CSPAN%3Epnp%3ATemplates%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSPAN%3Epnp%3AProvisioning%3C%2FSPAN%3E%3CSPAN%3E%26gt%3B%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EScript%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CSTRONG%3E%24XPath%20%3D%20%22%2F%2FFolder%22%3C%2FSTRONG%3E%3CBR%20%2F%3E%24nodes%20%3D%20Select-Xml%20-Path%20%24localPath%20-XPath%20%24XPath%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%3CBR%20%2F%3EBut%20%24nodes%20are%20%3CU%3Eempty%3C%2FU%3E.%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EHowever%2C%20the%20following%20code%20works%2C%20but%20will%20only%20get%20Folder%20nodes%20directly%20under%20Folders%3A%26nbsp%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%5Bxml%5D%24xml%20%3D%20Get-Content%20%24localPath%3CBR%20%2F%3E%24folders%20%3D%20%24xml.Provisioning.Templates.ProvisioningTemplate.Lists.ListInstance.Folders.Folder%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
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