XML : Get a list of all root-to-leaf paths in a DOM tree

So far I understood that when I parse an XML as a DOM object it is represented as a tree. I'm trying to get a list of all the paths from root to any leaf of my XML document (n-ary tree) with the TreeWalker, however I'm wondering if I should do my own implementation or there's any existing implementation defined. I found none in the official documentation.

Given the xml document:

  <node id="A">     <node id = "AA">         <node id = "AAA"></node>     </node>     <node id = "AB">     </node>     <node id = "AC">     </node>  </node>    

The expected list should contain:

  A, AA, AAA   A, AB  A, AC    

No comments:

Post a Comment