xml - PHP return specific number of nodes? -
if have large xml file format:
<person> <attribute>value</attribue> </person> <person> <attribute>value</attribue> </person> <person> <attribute>value</attribue> </person>
goes on hundreds of thousands of <person>
records....
how can i, using php, echo out file/return 'person' 1-10, 11-20, etc..
i have found ton of examples (xpath, etc..) returning nodes or node subsets, no examples of returning specific range of nodes.
my specific file has hundreds of thousands of <person>
nodes. want output in xml format <person>
s 1-50,000, 50,001-100,000, etc...
turned out simple. couldn't find specific example online, managed piece few different examples needed:
<?php $xml = simplexml_load_file('somexmlfile.xml'); $result = $xml->xpath('/enterprise/person[position()>=1 , position()<=10000]') ; while(list( , $node) = each($result)) { echo $node->asxml(); } ?>
Comments
Post a Comment