Faster way to render XML (10MB) file, loop the content and display output
There is no error handling.  Loading a remote resource is somewhat likely to fail.  Unfortunately, simplexml doesn't make error-handling easy.

Instead of filtering the XML using PHP code, I suggest selecting exactly the nodes you want using an XPath query.  The XPath library is more likely to be optimized than your PHP code.  In any case, it is certainly simpler to maintain one string describing the relevant nodes than a bunch of nested PHP statements.

I've chosen to use PHP templating for rendering, as it is easier to see that it is output.

&lt;?php
$xml = simplexml_load_file('http://www.example.com/example.xml');
foreach ($xml-&gt;xpath("//comment[ProdNid = '" . htmlspecialchars($productId) .
                     "'][PostedOn][PostedBy][comment_text][position() &lt;= 5]") as $comment) {
?&gt;
    &lt;div class='review_wrp'&gt;
      &lt;span class='review_product'&gt;&lt;?php echo htmlspecialchars($title);
      ?&gt;&lt;/span&gt;&lt;span class='review'&gt;&lt;?php echo htmlspecialchars($comment-&gt;comment_text);
      ?&gt;&lt;/span&gt;&lt;span class='review_person'&gt;&lt;?php echo htmlspecialchars($comment-&gt;PostedBy);
      ?&gt;,&lt;?php echo htmlspecialchars($comment-&gt;PostedOn); ?&gt;&lt;/span&gt;
    &lt;/div&gt;
&lt;?
}


All of those output strings probably need to be escaped to prevent, for example, cross-site scripting.  I've used htmlspecialchars() for that.