open file.xml ; for //node { $depth = count(ancestor::*) - 1 ; echo :s { ' ' x $depth } @name ': ' @text ; }