You can loop through
only the "real" elements by writing next_element( '#ELT').. You could also use the start_tag and end_tag methods for "real" elements and the xml_string element for text ('#PCDATA') element.
Alternatively, and I would reccomend that approach, you could generate the "extra html formating" as part of the document: adding attributes, inserting elements or wrapping existing elements in new ("formating") elements. Then you can output the twig (or parts of it) at once.
|