Results 1 to 3 of 3
  1. #1
    Newbie
    Join Date
    May 17th, 2007
    Posts
    1
    Problem parsing large datafeed with XMLReader
    Hi all,

    I have been trying to parse a 250MB xml file using PHP5's XMLReader.
    Below is a snippet of the code I'm using:
    PHP Code:
    $readerXMLReader::open('datafeed.xml');
    while (
    $reader->read())
    {
    if (
    $reader->nodeType == XMLReader::ELEMENT && $reader->name == "productname"){
            
    $reader->read();
            
    $productname addslashes($reader->value); 
        }    
    }
    echo 
    'End of product feed'
    This is working perfectly for small files but stops mid process (without any error messages) after about 10 seconds when processing test xml files around 14MB.

    Has anyone got any suggestions??

    Thanks in advance

  2. #2
    Newbie PublisherZilla's Avatar
    Join Date
    May 10th, 2007
    Location
    Los Angeles, CA
    Posts
    21
    not sure how useful it might be, but this article i found as a lot of useful info on xml. i didn't want to read through the whole thing, but your q may be answered in there. http://www.sitepoint.com/article/php...arsing-rss-1-0. if not, my bad.

  3. #3
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Quote Originally Posted by seo london
    This is working perfectly for small files but stops mid process (without any error messages) after about 10 seconds when processing test xml files around 14MB.
    I had this same problem except with much larger files (1gb+). My solution was to read the file in via fread and load chunks of the XML file into XML Reader. I had to connect broken items and add opening and closing tags to each chunk. Basically I broke one huge XML file into a bunch of bite-size pieces.

    - Scott
    Hatred stirs up strife, But love covers all transgressions.

  4. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Featured: TIP: Viewing large datafeed files
    By isellstuff in forum Programming / Datafeeds / Tools
    Replies: 11
    Last Post: July 6th, 2011, 09:52 AM
  2. Dealing with large datafeed files in PHP
    By MoreBeer in forum Programming / Datafeeds / Tools
    Replies: 4
    Last Post: April 6th, 2010, 07:03 PM
  3. Parsing XML using php simplexml_load_file()
    By Uncle Rico in forum Programming / Datafeeds / Tools
    Replies: 2
    Last Post: November 24th, 2008, 07:28 AM
  4. Parsing Pages of PopShops - Progress?
    By Caseyfern in forum PopShops
    Replies: 0
    Last Post: August 19th, 2008, 11:13 PM
  5. Large databases, problem.
    By Remy in forum WebMerge (Fourthworld.com)
    Replies: 6
    Last Post: October 8th, 2003, 01:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •