1

I'm using simpleXML and PHP to get a feed, then processing it in a foreach loop as normal.

I would like to recognise if the feed is huge and stop the processing of the feed, or if possible, stop the downloading of the feed completely, or cut it once it is over a set limit.

Are there any methods to do this?

David19801
  • 11,214
  • 25
  • 84
  • 127
  • 1
    No. SimpleXML will attempt to suck up the entire XML document in one go. To parse xml files which will potentially exceed memory limits, use: http://stackoverflow.com/questions/1167062/best-way-to-process-large-xml-in-php – Marc B Nov 15 '11 at 15:36

2 Answers2

1

You can use XMLReader for this

Jon Skarpeteig
  • 4,118
  • 7
  • 34
  • 53
0
  1. Download to Your tmp folder or check the size with curl
  2. Check the filesize
  3. Parse it
Community
  • 1
  • 1
Fedir RYKHTIK
  • 9,844
  • 6
  • 58
  • 68