I'm generating a ton of XML that is to be passed to an API as a post variable when a user click on a form button. I also want to be able to show the user the XML before hand.
The code is sorta like the following in structure:
<?php
    $lots of = "php";
?>
<xml>
    <morexml>
<?php
    while(){
?>
    <somegeneratedxml>
<?php } ?>
<lastofthexml>
<?php ?>
<html>
    <pre>
      The XML for the user to preview
    </pre>
    <form>
        <input id="xml" value="theXMLagain" />
    </form>
</html>
My XML is being generated with a few while loops and stuff. It then needs to be shown in the two places (the preview and the form value).
How do I capture the generated XML in a variable or whatever so I only have to generate it once and then just print it out as apposed to generating it inside the preview and then again inside the form value?