If you want to focus on the main taxonomic ranks, i.e. superkingdom, kingdom, phylum, class, order, family, genus & species, you can do the following :
efetch -db taxonomy \
-id 9606 \
-format xml \
| xtract -pattern Taxon \
-tab '\n' -sep '\t' \
-element TaxId,ScientificName \
-division LineageEx \
-group Taxon \
-if Rank -equals superkingdom \
-or Rank -equals kingdom \
-or Rank -equals phylum \
-or Rank -equals class \
-or Rank -equals order \
-or Rank -equals family \
-or Rank -equals genus \
-tab '\n' -sep '\t' \
-element Rank,ScientificName
Which yields :
9606 Homo sapiens
superkingdom Eukaryota
kingdom Metazoa
phylum Chordata
class Mammalia
order Primates
family Hominidae
genus Homo
Ps : All the doc for xtract is here : https://dataguide.nlm.nih.gov/edirect/xtract.html