XMLwriter add Flush In PHP loops
<p>I need to create <code>xml</code> File using PHP loop and xmlwriter. In action I have two <code>foreach</code> loop :</p>

<pre><code>$writer = new XMLWriter();
$writer-&gt;openMemory();
foreach ($nav as $k =&gt; $v) {
    $writer-&gt;openURI($abspath . '/cache/xmls/news-' . $k . '.xml.gz');
    $writer-&gt;startDocument('1.0', 'UTF-8');
    $writer-&gt;setIndent(4);
    $writer-&gt;startElement('urlset');
    $writer-&gt;writeAttribute('xmlns', $xmlns);
    foreach ($v as $k2 =&gt; $v2) {
        $writer-&gt;startElement('url');
        $writer-&gt;writeElement('loc', SITE . '/' . $v2);
        $writer-&gt;writeElement('lastmod', '');
        $writer-&gt;writeElement('changefreq', '');
        $writer-&gt;writeElement('priority', '');
        $writer-&gt;endElement();
        $writer-&gt;flush();
    }
    $writer-&gt;endElement();
    $writer-&gt;endDocument();
    $writer-&gt;flush();
    $writer-&gt;outputMemory();
}
</code></pre>

<p>I add <code>Flush();</code> for each loop.</p>

<p>1- In action add <code>flush()</code> for each loop is TRUE? Or I need To Add One <code>flush();</code> for all loops?! </p>

<p>2-I add <code>openmemory();</code> This is True After <code>Fulsh();</code>?</p>