I'm not sure I understood what you want to do, but some time ago I did something similar to a paging putting a counter inside the foreach
Code:
<?php
$xml = simplexml_load_file("camsx.xml");
foreach($xml->children() as $child){
$gal[$child->getname()] = $child[0];
foreach($child as $ch){
$gal[$ch->getname()] = $ch[0];
}
if($gal['sex']=="Female" && $n < 1000 && $gal['showmode'] == "free"){
/////////////////////
$start = $_GET['start'];
$stop = $_GET['start']+5;
if($n > $start && $n < $stop){
///////////////////////////////
?><div id="grid"> <div class="host_box">
<a href="/<? echo $gal['screenname']; ?>" target="_self" "><img src="<? echo $gal['liveimage']; ?>" alt="<? echo $gal['screenname']; ?>"><br>
<? echo $gal['screenname']; ?></a>
</div>
<?php
////////////////////
}
////////////////
$n++;
}
}
?></div>
$start in my case is passed in GET.
Load anyway the whole xml, but shows only a few lines of output