Select tagged frames

I need to select all Indesign tagged frames (Structure/Show Tagged Frames) & create a layer & move them to a layer. this time I have no idea of how to that don’t know if even possible. I never worked with XML & Structures before. Any suggestions