Closed magna25 closed 7 years ago
See examples/serialize.cc that uses recursion to walk and rebuild the tree here: https://github.com/google/gumbo-parser/blob/master/examples/serialize.cc
Also see https://github.com/google/gumbo-parser/pull/392/commits/7f73b3b836ae75bb40c3ce1bff46c1ac913a2cae
A pull request that includes a non-recursive tree traversal routine.
Thanks
@kevinhendricks found the recursive function very useful but was wondering if there was anyway to determine the relationship (parent and child) between the nodes. Is there like has_children()
method or something?
In the recursion routine serialize_contents processes each child of the parent it is called from in serialize. Please examine gumbo.h for info on the node structure, how children are stored, and how access pointer back to parent is stored.
This might be a silly question but can't find the examples on how to walk the output tree.