Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Can SimpleXML load only a partial of a XML?
- $feed = 'rss file';
- $xml = simplexml_load_file($feed); //not the entire feed though
- $xml = simplexml_load_file($feed);
- $top10 = $xml->xpath('/rss/channel/item[position() <= 10]');
- foreach($top10 as $item) {
- // output $item;
- }
- $xmlr = new XMLReader();
- $xmlr->open('path/to/file');
- // ...
- // move the pointer with $xmlr->read(), $xmlr->next(), etc. to the required
- // elements and read them with simplexml_load_string($xmlr->readOuterXML()), etc.
- // ...
- $xmlr->close();
Add Comment
Please, Sign In to add comment