in reply to Re^2: XML::Twig and paste
in thread XML::Twig and paste

To print the document: $t->print prints the entire document. You don't have to do the inner loop yourself.

Replies are listed 'Best First'.
Re^4: XML::Twig and paste
by jezzica85 (Initiate) on Jul 25, 2007 at 17:24 UTC
    I need to put some extra html formatting before the XML before I print it, though, and the formatting depends on the element, so I do need to do the inner loop to get each element. So, I guess I'm still kind of confused here--if paste puts in 2 elements, the actual element and its text, how do you print out the element, and not that secondary text element? Sorry if I sound like a broken record; I still don't understand. Jezzica85

      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.

        Thank you so much mirod, that worked! I'll keep the other stuff you mentioned about twigs in mind, too. Jezzica85