in reply to question in Xml::Twig

I am not sure I really understand the question. $twig->safe_parse($str) is a twig object, not a string. If you want a string (the xml for the document in the twig) then you need $twig->sprint. Does this answer your question?